in reply to Re: pcre regex
in thread pcre regex

how do i substitute ^ and $ in my regex

Replies are listed 'Best First'.
Re^3: pcre regex
by moritz (Cardinal) on Apr 06, 2012 at 11:28 UTC
    Well, what semantics do you want?

    If you just want to remove the restriction that the regex has to match the whole string, remove them.

      I substituted and changed ^ and $ but still not getting matches

      (?<=)\d{4}[A-Z0-9](?=)

        What do you think (?<=) and (?=) do? Why did you write them?

        The regex you wrote matches a string like 4444B within a longer substring, so maybe you're doing something else wrong.

        This might do what yo uwant:
        \b\d{4}[A-Z0-9]\b
        The \b restricts the matches to word boundaries, so it won't report matches in the middle of a longer "word" (which may include digits), like "123456789ABCD".