linquize
linquize

Reputation: 20396

Regular Expression match no dot characters

How to use Regular Expression to find?

1) abc.def

2) abc.fgh.ijk

3) abc.m.nop.pqrs

I only want the first one, which contains only one dot and starts with "abc"

Upvotes: 0

Views: 1022

Answers (2)

Seimen
Seimen

Reputation: 7250

^abc\.\w+$

This matches if the string starts with "abc." and then any word character until the end of the string, which excludes dots.

Upvotes: 0

Felix Kling
Felix Kling

Reputation: 817198

Use an expression that matches a string starting with abc. and then any character that is not a .:

^abc\.[^.]+$

http://www.regular-expressions.info/ is a good place to start learning regular expressions.

Upvotes: 4

Related Questions