Home > Enterprise >  regex to find a 44 length string after " - "
regex to find a 44 length string after " - "

Time:05-09

I have the following regex that will find a string length of 44 digits / letters:

^[A-Za-z0-9]{44,}$

the problem is that my text file is built like that:

XXXXX - SOMETHINGSOMETHINGSOMETHING55252
XXXXX - SOMETHINGSOMETHING985295829

So, I want the search to start after the "space - space" I tried to do it by my self with out success :( Thanks in advance

CodePudding user response:

Use

(?<=- )[A-Za-z0-9] $

See regex proof.

EXPLANATION

- Positive Lookbehind (?<=- ) assert that the Regex below matches the characters "- " literally (case sensitive) on the left
- [A-Za-z0-9]  - Match a single character present in the [A-Za-z0-9] list between one and unlimited times, as many times as possible, giving back as needed (greedy)
- $ - asserts position at the end of a line
  • Related