Reputation: 971
I have the following set of strings - "Hello.There"
and "HelloWorld.There"
If I do a 'Hello.*'
, RegEx returns both strings. How do I change my expression to return only "Hello.There"
?
Upvotes: 1
Views: 86
Reputation: 785058
You can use word boundaries in your regex:
^Hello\b.*$
With word boundaries it won't match HelloWorld
Upvotes: 3
Reputation: 39355
Your regex should be Hello\.
if you want to return the string when its only contains Hello.
In regex a dot(.) means any character. You can escape this by using a escape character like this \.
Upvotes: 0
Reputation: 1870
Try this expression
[Hello.]*
gskinner is a simple and good webseite to experiment with Regex
Upvotes: -1
Reputation: 2372
\bHello\.There\b
the .
character is a special character in Regex. Escape it.
Upvotes: 0