Page 1 of 1

rex help

Posted: Tue Dec 04, 2007 12:42 pm
by jason.elder
Hi,
Looked throught the forum here and it seems the use of $ in rex is confusing.

I have some text:

...
Language: English
LargeImage: grants-content-image-campbeltown.jpg
Author: George Bowie
CreationDate: 2003-09-11 14:57:53
...

all in the same var.
what i want to do is extract the Author: value (the line minus the "Author:" bit)

if i use ">>Author: \P=.+" , I get

George Bowie
CreationDate: 2003-09-11 14:57:53
...

(side question...if i use rex on the command line with the same expression i get

Author: George Bowie
CreationDate: 2003-09-11 14:57:53
....

why is that?)

Anyway, if i use ">>Author: \P=.+$" or ">>Author: \P=.+\F$" it doesn't work.
What is the correct syntax for getting everything up to the end of the line?

rex help

Posted: Tue Dec 04, 2007 12:44 pm
by jason.elder
To elaborate, all I want to return is "George Bowie"

rex help

Posted: Tue Dec 04, 2007 1:11 pm
by mark
REX doesn't care much about newlines, unlike other regular expression matchers. I prefer to use \x0a instead of $ in most cases to avoid any confusion. You need

>>Author: \P=[^\x0a]+

Your ".+" ate the newlines already so there are none to follow.

rex help

Posted: Tue Dec 04, 2007 1:25 pm
by jason.elder
Ah fantastic!
I forgot about the greediness of regex.

Thanks very much for the speedy reply.