0

How do I deal with quotes here?
What i want is /[^a-zA-Z0-9-_.,!()'\/"]/ but how do i deal the quotes?

$pattern = '/[^a-zA-Z0-9-_.,!()'"\/' . $whatever . ']/';
return preg_replace($pattern, '',  $value);

Cheers!

2
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by woopi
0

Hi pritaeas , thank you.
I understand that but how do i combine escape both for php and preg_replace?

1

For the backslash it would look like this:

preg_match('%[^a-zA-Z0-9-_.,!()\'"\\\\/]%s', $subject)

As mentioned in the first note in the first link, first escape for the regex, and then for the php string.

0

Sorry for not really understanding ...
so a single backslash will escape single quote for php in this case and preg_match won't bother with it?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.