Forums Register Login

Pattern.matches woes

+Pie Number of slices to send: Send
Hello, I am using regex to check some links on my code and basically I I want to know whether they have certain words in those urls.

The way I am checking this is below:


apparently matches tries to match for the whole newurl to google. I tested it by changing the newurl = "google" and it returned me true. so can someone address me what I am doing wrong here?

thanks a lot.
+Pie Number of slices to send: Send
Instead of using Pattern.match() which does match the entire string, why not just use another Matcher and its find() method to see if part of the string matches the term?

The other option is to use a regex pattern that will catch any prefix or suffix to the desired pattern. So .*google.* as an example.
+Pie Number of slices to send: Send
thanks!!
working like a charm.
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 819 times.
Similar Threads
Regex for number and period..Like version
String Replace
String replace for URLs
regex confusion.
String/Character Problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:19:18.