0

The regex is [^\r\n.!]*(?i)tel*[^\r\n]+ but it somehow could detect the words telephone and testing.

But why testing? I don't get this because the l is explicitly written in the regex.

https://regex101.com/r/7Z8KkK/1

At Regex101, it explains...

te matches the characters te literally (case insensitive)
l matches the character l with index 10810 (6C16 or 1548) literally (case insensitive)

But I don't understand the explanation and why it views te and l separately.

bafew80778
  • 19
  • 3
  • 1
    Well `l*` means the letter `l` zero or more times. Perhaps you intended to use: `[^\r\n.!]*(?i)tel.*[^\r\n]+` ? – Tim Biegeleisen Mar 28 '23 at 02:25
  • That should be an answer @TimBiegeleisen and you beat me to it :D – Jorge Campos Mar 28 '23 at 02:27
  • The `*` after the `l` says you can have the letter l 0, 1 or many times. testing is l 0 times. if you the entire string "tel" to be affected by the *, put it between (): (tel)* – Pabluez Mar 28 '23 at 02:27
  • To add to it it will match any word that has "te" on it. – Jorge Campos Mar 28 '23 at 02:28
  • @TimBiegeleisen My intention is to read "tel" not "tel." but I followed what Pabluez said by using "(tel)" but it doesn't work. Testing still gets matched. – bafew80778 Mar 28 '23 at 02:33
  • @TimBiegeleisen Should I just remove the * meaning "tel" instead of "tel*" to detect "tel" literally? – bafew80778 Mar 28 '23 at 02:35
  • `tel` matches `t`, `e`, `l`. `tel*` matches `t`, `e` and any number of `l`. `(tel)*` matches any number of repetitions of the sequence `t`, `e`, `l` (it matches the string containing `testing` because there are 0 repetitions of `tel`). `(tel)+` matches any _positive_ number of repetitions of this sequence (so it would not match `testing`). And `tel.*` matches `t`, `e`, `l`, and any number of repetitions of any character (not just `.`). – Amadan Mar 28 '23 at 02:45

0 Answers0