0

I want to isolate all CLIENT.xxxx in this string:

CLIENT.TEST,Toto.test,Test.Test,CLIENT.NOM,
Zozo.zaza,CLIENT.Machin,Truc.Chose,Truc.tralala,

I use this regular expression: CLIENT\..*[\,\)]. But, as you can see at https://regex101.com/r/LKD50F/1 not only CLIENT.xxxx match the expression but also Toto.test, Test.test, and so on.

How can I modify my regexp to match only CLIENT.xxxx ?

coutier eric
  • 949
  • 5
  • 18
  • 1
    `CLIENT\.\w+[\,\)]` ? – Maciej Los Jul 09 '21 at 11:12
  • 1
    `.*` is greedy; you should make it lazy (i.e., `.*?`). Additionally, `,` doesn't need to be escaped and `)` inside a character class also doesn't need to be escaped. So, you could just use `[,)]`. One more thing, you might want to throw a `\b` before `CLIENT` to avoid matching something like "MULTICLIENT", for example. – 41686d6564 stands w. Palestine Jul 09 '21 at 11:25
  • @41686d6564 your anwser is the best one for me, especially for \b tip, the explanation of question mark to use lazy and the tip about not espacing inside []. So you can convert your comment into anwser and I will accept it – coutier eric Jul 09 '21 at 12:10

1 Answers1

1

Try this: CLIENT\.\w+[\,\)]

regex-demo

Maciej Los
  • 8,468
  • 1
  • 20
  • 35