Reputation: 33
I am trying to write a program in which I have to do comparison between a list of strings with a template (which is essentially a string). I am not sure what is the term used but it is going to be more of log scraping program if that helps.
Input String Examples:
To be compared against
a. This is a ? file
b. Hello World this is ?
The idea is to match input statements (1-4) against template strings (a-b) and if they match then I need to act on them. Like 1 & 4 match sentence b but 2 does not.
Thanks in advance for help/directions.
Upvotes: 3
Views: 1332
Reputation: 425198
Change your ?
to .*
and you've got a regex:
String input = "Hello World this is me";
if (input.matches("Hello World this is .*"))
// true
etc
Upvotes: 1