One Two Three
One Two Three

Reputation: 23517

regex for checking if a string matches a package or the other

I'm trying to check if a string looks like my.company.foo.A or your.whatever.bar.B.

The point is, I want to match or strings that have .bar. or .foo. And I have this regex (.*\\.foo\\..* | .*\\.bar\\..*)

but which didn't seem to work.

Can someone help me out here?

Upvotes: 0

Views: 42

Answers (1)

Jorge Campos
Jorge Campos

Reputation: 23381

The problem is the space on your regex:

(.*\\.foo\\..* | .*\\.bar\\..*)
              | |

Take it out and you should be fine

(.*\\.foo\\..*|.*\\.bar\\..*)

Upvotes: 1

Related Questions