0

(?:[^.]|^)((?:\b(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|0?[0-9]?[0-9])\.){3}(?:\b(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|0?[0-9]?[0-9]))\b(?=[^.:/]|$))

this highlights correct IPv4 address, but if at front there are any special characters, it also highlights the same.

11.22.44.33 - OK

@11.22.44.33 - also highlights 1st character - @, which I don't want. I just want to highlight rest of the part

1 Answer 1

0

The @ will match your REGEX, but it won't be captured in your capturing group.

I'm not sure what software you're using it with, but group 1 will contain just the IP address, and not the @.

If you simply don't want it to match at all for whatever reason, remove the first part of your REGEX:

(?:[^.]|^)

As this matches anything that isn't a literal . or the beginning of a line/string. I'm not sure you actually need this part anyway.

2
  • Thanks for the suggestion, but my requirement is to highlight correct iPv4 address. instead of @ or any other special character, if you add "Space" it also highlights the same, which I don't want Dec 29, 2015 at 14:17
  • Highlight in what though? You are capturing the exact iPv4 address in group 1, can you not use this data? I don't fully understand your requirement, do you mean you only want to match if there is absolutely nothing else in the same string?
    – Jonno
    Dec 29, 2015 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .