ot - I need a geek (regexps or similar)

Discuss music production with Ableton Live.
Post Reply
noisetonepause
Posts: 4938
Joined: Sat Dec 28, 2002 3:38 pm
Location: Sticks and stones

ot - I need a geek (regexps or similar)

Post by noisetonepause » Sun Jan 07, 2007 2:50 pm

Hello, Forum!

I've got a small problem.

I'm writing an essay for school(uni) and I want to do the typesetting in (Te)TeX, cos it renders things all lovely, and I need to put a few arabic words in there and TeTeX, well, renders Arabic transliteration all lovely:)

I've just written plain text files, but now I need to do some pattern replacements for my footnotes. Basically in my text files I've got the pattern (NOTE: ...text...) which I need to replace with \footnote{...text...}.

I know I can do this with regexps in my editor easier than standard search & replace, but I'm not sure exactly how it works.

I've got Unix sed and awk and what have ye as well, but I don't know how to use them.

If anyone could give me some pointers, I'd be much full of grate.

Tar,
Paws
Suit #1: I mean, have you got any insight as to why a bright boy like this would jeopardize the lives of millions?
Suit #2: No, sir, he says he does this sort of thing for fun.

earsmack
Posts: 253
Joined: Sat Jul 08, 2006 12:07 pm
Contact:

Post by earsmack » Sun Jan 07, 2007 8:38 pm

There are plenty of real good regex tutorials (using a variety of apps) online - google it.

bandbajao
Posts: 42
Joined: Wed Aug 23, 2006 4:06 am
Contact:

Post by bandbajao » Sun Jan 07, 2007 10:50 pm

man, this topic is waaay OT :lol:

if the text you need to search for is -
(NOTE: ...text...)
then search for ^\(NOTE:(.+)\)$
and replace with \footnote{$1}

if the text you need to search for is -
NOTE: ...text...
then search for ^NOTE:(.+)$
and replace with \footnote{$1}

this is posix. if you're using textpad, use \1 instead of $1 in the replacement expression.

MrYellow
Posts: 1887
Joined: Mon Dec 15, 2003 7:10 am
Contact:

Post by MrYellow » Mon Jan 08, 2007 12:03 am

Yeah music by regexp!

[T][o]{2} [C][o]{2}[l]

-Ben

mikemc
Posts: 5464
Joined: Mon Jun 21, 2004 2:14 pm
Location: Maryland USA

Post by mikemc » Mon Jan 08, 2007 2:04 am

get perl. if it is a small text file, then

(your standard perl heading goes here)

$pattern= the old thing; # you need to escape this properly
$newpattern = the new thing; # same as above

while(1){
$modifiedString = $_;
$modifiedString =~ s/$pattern/$newpattern/g;
print $modifiedString;
}

pipe the text file to the above script
UTENZIL a tool... of the muse.

noisetonepause
Posts: 4938
Joined: Sat Dec 28, 2002 3:38 pm
Location: Sticks and stones

Post by noisetonepause » Wed Jan 10, 2007 3:22 am

Thanks all.

The essay turned out beautiful... typographically speaking, at least:)

Must learn to start earlier!
Suit #1: I mean, have you got any insight as to why a bright boy like this would jeopardize the lives of millions?
Suit #2: No, sir, he says he does this sort of thing for fun.

Post Reply