Home > OS >  Building Regex pattern to accommodate all these words
Building Regex pattern to accommodate all these words

Time:10-22

I am building a regex code pattern to find extract the below words from the logs.

My current regex code is[A-Z0-9a-z-]{8,36}

The following words are getting identified using the above regex code.

a60a4c82-82ea-4ff3-ac64-f4450d45e72e
0222bfb3
2110122003513063314

Regex code needs to be modified to accommodate/identify the below string using the above regex code. Any Suggestions/help in modifying current regex query to implement all string in single regex expression will be hight appreciable.

      Current string                         Required String

SAR- 96599853915-63aa6d10-2-2Mobile           SAR- 96599853915-63aa6d10-2-2
63AA6CBDMobile                                63AA6CBD
<CSError>                                     CSError

The Word "Mobile" is another filed but as it has no space between the srting in the logs, Mobile word gets attached with string that's why I don't want the "Mobile" in the string.

Thanks in Advance.

CodePudding user response:

You can use

(?:(?!Mobile)[A-Z0-9a-z -]){7,36}

See the regex demo.

It matches 7 to 36 occurrences of any ASCII letters, digits, or - chars that do not start a Mobile char sequence.

  • Related