- AuthorPosts
- July 14, 2011 at 12:11 am #9468DeipotentParticipant
If you have lines of the following format “ABCDE: .abc3;.s32”, and have incremental search enabled, all matching lines are highlighted with a regex of “: . *(.([[:alnum:];.])*)”, but only a single match is highlighted with “: . *(.([[:alnum:];.])*)n”
July 14, 2011 at 1:46 am #9470CrashNBurnMemberI’m confused as to what you are searching for.
Especially since you are using multiple instances of “*”
— Which with regex are rarely necessary, and frequently will mangle your search results.[[:alnum:];.] —> means match *ANYTHING*
You haven’t escaped the period. and it will match any char.
Possibly you meant:
[[:alnum:];.]But then, this: ([[:alnum:];.])*
Means match any alphanumeric plus semi-colon plus a dot any number of times, or not at all. Meaning it will also match empty lines – that only have a carriage return.Possibly, what you meant as your regex:
: ([[:alnum:];.])+n
July 14, 2011 at 2:03 am #9472DeipotentParticipantYou are correct that the first period is not necessary, that the period in the character set should be escaped, and that the second * should be a +. My regex is a little rusty.
The first * should also be a +, as I want it to match one or more spaces, so the regex should probably be
: +([[:alnum:];.]+)n
The issue I reported with only a single match being highlighted is still present, even with the updated regex.
July 14, 2011 at 2:38 am #9476CrashNBurnMemberMy Test file:
teststring
teststring
teststring
teststring
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32This regex,
: +([[:alnum:];.]+)n
Matches the first 3 ABCDE lines.
This regex,: +([[:alnum:];.]+)$
Matches all 4.
And with this file:teststring
teststring
teststring
teststring
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32This regex:
:[ ]+([[:alnum:];.])+$
Matches all 4 ABCDE’s.
And with this file:
teststring
teststring
teststring
teststring
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32
ABCDE: .abc3;.s32
This regex:
:[ ]+([[:alnum:];.])+n
Matches all 4 ABCDE’s.
July 14, 2011 at 2:46 am #9477DeipotentParticipantIn your last two regex’s you place the space in square brackets (ie. “[ ]” instead of ” “). Why is this ?
Is that considered a better/clearer way of writing it ?
July 14, 2011 at 3:13 am #9480CrashNBurnMemberI do it so I can see at a glance that there is in fact a space being matched.
Regex strings are hard enough to look at as it is :-)
Functionally it is likely no different, but visually, and for working with them, much easier for me to figure out:
[ ]+ than
+ - AuthorPosts
- You must be logged in to reply to this topic.