jrpz
jrpz

Reputation: 93

Regular expression not working

I want to extract from the following regex (?<=^\d+\s*).*?\t trying to extract from the following text just the resources\blahblah: 10 _Resources\index.test FAIL 11 _Resources\index.test FAIL 12 Resources\index.test FAIL 13set\Relicensing Statement.test FAIL

but it captures the following text: 0 _Resources\index.test
1 _Resources\index.test 2 Resources\index.test
3set\Relicensing Statement.test

I just want the lines like Resources\index.test and not the starting numbers, no spaces, why is failing? If I just execute ^\d+\s*and matches with the any number of digits and space, but do not works with prefix.

Upvotes: 0

Views: 62

Answers (2)

Aaron
Aaron

Reputation: 24802

Since you commented you were using Notepad++, how about matching ^\d+\s*([^\t]*).*$ and replacing by \1 ?

Upvotes: 1

logi-kal
logi-kal

Reputation: 7880

From NSRegularExpression (I saw it was tagged):

Look-behind assertion. True if the parenthesized pattern matches text preceding the current input position, with the last character of the match being the input character just before the current position. Does not alter the input position. The length of possible strings matched by the look-behind pattern must not be unbounded (no * or + operators.)

The same problem holds in most of the languages.

Can't you extract $1 from (?:^\d+\s*)(.*?\t)?

Upvotes: 0

Related Questions