Full word RegEx

If I want to change below

Hello

To:

HELLO

Ok when i do \(Hello)\

But he's working on words like:

HeLLo hello HellO

Is there a way to get a regex for all characters hello

?

+2


source to share


2 answers


Depending on your regex engine there should be a way to specify case insensitivity.

For example, in Perl:

/Hello/i

      

or Python:



re.compile(r"hello", re.IGNORECASE)

      

Alternatively, you can do it manually for each character:

[Hh][Ee][Ll][Ll][Oo]

      

+5


source


use for example your library vulnerability modifier

/hello/i

      



It would also be wise to add \ b, the word separator, so you don't select "ahello".

/\bhello\b/i 

      

+4


source







All Articles