Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #9468
    Deipotent
    Participant

    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”

    #9470
    CrashNBurn
    Member

    I’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

    #9472
    Deipotent
    Participant

    You 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.

    #9476
    CrashNBurn
    Member

    My Test file:

    teststring
    teststring
    teststring
    teststring



    ABCDE: .abc3;.s32
    ABCDE: .abc3;.s32
    ABCDE: .abc3;.s32
    ABCDE: .abc3;.s32

    This 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;.s32

    This 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.

    #9477
    Deipotent
    Participant

    In 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 ?

    #9480
    CrashNBurn
    Member

    I 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
    +

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.