stratofortress
stratofortress

Reputation: 453

string matches method in java when wanting to compare two dollar signs (not escaping)

I have the simplest of code thats supposed to compare two string inputs as follows:

public class Validate {
    public static void main(String[] args) {
        String re = args[0];

        String input = args[1];

        System.out.println(input.matches(re));
    }
}

It works as expected except if your two inputs are $and$, it just prints out false. I did hear about how you have to escape any special regex characters, including dollar sign.

But what if you want to compare two dollar signs and print out true

Upvotes: -2

Views: 298

Answers (1)

Arif Burhan
Arif Burhan

Reputation: 505

In bash $$ is substituted by the ProcessID a small integer.

Upvotes: -1

Related Questions