rex help

Post Reply
jason.elder
Posts: 15
Joined: Wed May 16, 2007 11:53 am

rex help

Post 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?
jason.elder
Posts: 15
Joined: Wed May 16, 2007 11:53 am

rex help

Post by jason.elder »

To elaborate, all I want to return is "George Bowie"
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

rex help

Post 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.
jason.elder
Posts: 15
Joined: Wed May 16, 2007 11:53 am

rex help

Post by jason.elder »

Ah fantastic!
I forgot about the greediness of regex.

Thanks very much for the speedy reply.
Post Reply