Questions tagged as 'preg-replace'

2
answers

Regular expression to reorder string

I have the result of a query with several joins , and in a row I have the concatenation of 2 groups. The line returns a string as: 1,4|a1,b4 . What I need is to regroup ID and Value as follows: array( 1 => a1 , 4 =>...
asked by 20.11.2015 / 01:49
1
answer

How to replace each match instance of a regular expression with a different value?

I have text (html code) with several images in standard HTML format: <img src="X" atributos /> I need the src attribute value to be replaced with the CID: # identifier where # is a unique value that identifies each image...
asked by 27.06.2018 / 18:53
1
answer

Problems with PHP regular expressions?

I'm picking up a .txt file and removing the letters and lines in white. Tá giving problem with the special character \t or \s it does not recognize. The code below: <?php function pass1() { $treat = fopen ("C:\U...
asked by 13.02.2017 / 19:03
1
answer

Problem with Regular Expression

preg_match('<[ \w"=]+name="xhpc_composerid"[ \w="]+>',$exec,$result1); echo $result1[0]; //input type="hidden" autocomplete="off" name="xhpc_composerid" value="u_0_1k" preg_match('/value="[\w]+"/i',$result1[0],$result2); echo $result2[0];...
asked by 13.03.2015 / 02:46
2
answers

Problem with Regex in PHP

I have the following function that is used to take special characters from a string: function removeSpecialChars($string){ //List (Array) of special chars $pattern = array("/(á|à|ã|â|ä)/","/(Á|À|Ã|Â|Ä)/","/(é|è|ê|ë)/","/(É|È|Ê|Ë)/","/(í|ì|...
asked by 11.12.2018 / 14:10
1
answer

preg_replace PHP - / or @, why put?

Using preg_replace () in PHP, I came across the following situation: echo preg_replace('/:([\w]+)/', 'batata', ':quiabo/isso/:nada'); echo preg_replace('@:([\w]+)@', 'batata', ':quiabo/isso/:nada'); Both expressions print the same thing: p...
asked by 22.04.2015 / 22:36
3
answers

exchange char Z for S between vowels in a string

How can I change all occurrences of the letter Z between S within a string for example    TEREZA, CEZAR, BRAZIL, ANZOL would be    TERESA, CESAR, BRAZIL, ANZOL     
asked by 11.08.2016 / 17:09
2
answers

Highlighted searched term in bold with or without accent

Hello friends, I would love your help. I'm trying to highlight the words typed in bold in search. the code below works only if you type "Brazilian selection" plus if you type "soccer selection" nothing happens. Thanks in advance for the help .....
asked by 04.08.2015 / 03:59
2
answers

How to make a preg_replace with several conditions and several changes?

How to make a PREG_REPLACE having several search and multiple substitutions at the same time For example, I want to ('/(BR|BL)/', 'B') if you have BR and BL replace with B and also ('/PH/', 'F') if you have PH replace wi...
asked by 02.09.2016 / 17:54
1
answer

Detect if link is current or external domain with PHP

I'm currently using this expression with preg_replace to detect links in content sent via POST : $conteudo = $_POST["conteudo"]; $conteudo = preg_replace('!(\s|^)((https?://|www\.)+[a-z0-9_./?=&-]+)!i', ' <a class="link_ex...
asked by 10.05.2015 / 05:03