Category : regex

I have this string: $shortcode = ‘[csvtohtml_create include_rows="1-10" debug_mode="no" source_type="guess" path="largecsv" source_files="test?output=csv" csv_delimiter="," ]’ I want to retrieve attributes and their values even their equal-signs or spaces within quotes. This question is based on this question: How to explode a string but not within quotes in php? I have this code: $args = preg_split(‘/"[^"]+"(*SKIP)(*F)|h+/’, $shortcode); ..

Read more

I need to replace a string that contains <?php echo $test; ?> with "Hello world". strpos($string_with_php_tags,’&lt;?php echo $test; ?&gt;’) !== false) // <– not working $hello = str_replace(‘&lt;?php echo $test; ?&gt;’, ‘hello world’, $string_with_php_tags); // not working. Is this possible with PHP? I couldn’t find a way to escape from this. Perhaps a regex? Thanks ..

Read more

I need to replace a string that contains <?php echo $test; ?> with "Hello world". strpos($string_with_php_tags,’&lt;?php echo $test; ?&gt;’) !== false) // <– not working $hello = str_replace(‘&lt;?php echo $test; ?&gt;’, ‘hello world’, $string_with_php_tags); // not working. Is this possible with PHP? I couldn’t find a way to escape from this. Perhaps a regex? Thanks ..

Read more

I have a= api in php on local i am getting proper response but on server first time i am getting response in ��V*.I,)-V�2�Q�M-.NLOU�RR�QJI,IT����QJ�()3k}. like this i am not using any encryption method.Sometime it is giving proper response but sometime it is not giving proer response. Any idea how can i resolve this issue? Source: ..

Read more

I need to convert all big integers to strings in my response json. Currently my regex look like this preg_replace( ‘/:s*(-?d{16,})/’, ‘: "$1"’, $content ); But problem with such regex is that if my response contains another json string then bigints inside it will be wrapped in string too, but without escaping. Is there any ..

Read more

I’ve a problem with a preg_match script. $regex = "/^(87.[5-9][50]|8[8-9].d[05]|9d.d[05]|10[0-7].d[05])|108.00$/"; if (!preg_match($regex, $_POST[‘numbers’])) { $error = ‘<div class="alert alert-danger">Wrong number.</div>’; } The regex is checking good, 109.00 isnt matched but when i enter 95.000 or 87.501 its mathing in php. When i use regex101 it’s not matching. I want only 2 numbers after point. How ..

Read more