Nathan B
Nathan B

Reputation: 1

Java Regex - Checking for Carriage Return

I am writing a regex to capture SQL Injection Keywords on the HTTP request. I am having problems with allowing 0 or more carriage returns.

I have tried \s but I get the error 'errorInvalidEscaperChar'.

If I put \s then this will be taken as a literal \s.

Any ideas please?

Thanks

N

Upvotes: 0

Views: 1650

Answers (3)

Jacek L.
Jacek L.

Reputation: 1416

"\" is a citation character in regexp and Java. So you need to write \\s

Upvotes: 1

Tim Büthe
Tim Büthe

Reputation: 63734

You have to escape the backslash in Java Strings. So, to get a backslash followed by an s, you need to write: "\\s".

But let's take a step back, what are you trying to achieve? Searching in parameters for "SQL Injection Keywords" might be a bad idea. Could you provide some details?

Upvotes: 1

Bala R
Bala R

Reputation: 108957

You'll have to escape the \ in your string. try "\\s".

Upvotes: 1

Related Questions