a regular expression that matches non-specific words

Asked 1 years ago, Updated 1 years ago, 78 views

I'm worried because I can't use regular expressions that match only certain words.

If you want to find a word that is not int, I wrote the following:

\b(?!int).)*\b

If you search for the following expressions in this regular expression, everything will not get stuck.

int integer interval

I don't want int to get stuck, but what regular expressions should I use when I want to search integer or interval?

Please let me know if anyone understands.

regular-expression

2022-09-30 21:24

1 Answers

As a perl compliant regular expression

I don't want int to get stuck, but when I want to search integer or interval

If means "I want to search for words that start with int other than int",

\bint\S+

If you want to find a word that is not int,

\b(?!int)\S+|int\S+\b


2022-09-30 21:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.