I want remove double quote in my json_encode, that is my code: My result is that: I want to remove double quote of “id_posiciones” and “device_version” too. How can I do for the result is that: Answer If you add an underscore to your regex at the end it will do it. I assume that’s what that preg_replace is for
Tag: preg-replace
Optimizing regex for sentence sanitizer
This is a sentence sanitizer. This is the test sentence: hello [[[[[[]]]]]] friend…..? how are you [}}}}}} It should return: hello friend…..? how are you But instead it is returning: hello friend. .. .. ? how are you. So there are 2 problems and I can’t find a solution around them: the set of periods are being separated into “..
Wrap first word in tag with preg_replace — can’t reference fullstring match
I generated the following regex code with http://gskinner.com/RegExr/ where it works, but when I execute it with PHP, it fails to use the match in the replacement string. Output: Expected: I know that obviously the $& is not doing the correct thing, but how can I get it to work? Answer Try with this instead $0 means it will become
PHP preg replace only allow numbers
How can I modify this existing preg_replace to only allow numbers? Answer I think you’re saying you want to remove all non-numeric characters. If so, D means “anything that isn’t a digit”:
Replacing accented characters php
I am trying to replace accented characters with the normal replacements. Below is what I am currently doing. $string = “Éric Cantona”; $strict = strtolower($string); echo “After Lower: “….
Strip all non-alphanumeric, spaces and punctuation symbols from a string
How can I use PHP to strip out all characters that are NOT letters, numbers, spaces, or punctuation marks? I’ve tried the following, but it strips punctuation. Answer Example: p{P} matches all Unicode punctuation characters (see Unicode character properties). If you only want to allow specific punctuation, simply add them to the negated character class. E.g: