How to make this regular expression?
I want to replace all line break (<br> or <br />) in a string with PHP. What regular expression I should have to do this, using preg_replace? Thanks! ...
I want to replace all line break (<br> or <br />) in a string with PHP. What regular expression I should have to do this, using preg_replace? Thanks! ...
$regexp = '/(?:<input\stype="hidden"\sname="){1}([a-zA-Z0-9]*)(?:"\svalue="1"\s\/>)/'; $response = '<input type="hidden" name="7d37dddd0eb2c85b8d394ef36b35f54f" value="1" />'; preg_match($regexp, $response, $matches); echo $matches[1]; // Outputs: 7d37dddd0eb2c85b8d394ef36b35f54f So I'm using this regular expression to search for an a...
This is the input string "23x +y-34 x + y+21x - 3y2-3x-y+2". I want to surround every '+' and '-' character with whitespaces but only if they are not allready sourrounded from left or right side. So my input string would look like this "23x + y - 34 x + y + 21x - 3y2 - 3x - y + 2". I wrote this code that does the job: Regex reg1 = n...
I've want to match any occurrence of a search term (or list of search terms) within the tags of a document. My current solution uses preg (within a Joomla plugin) $pattern = '/matchthisterm/i'; $article->text = preg_replace($pattern,"<span class=\"highlight\">\\0</span>",$article->text); But this replaces everything within the HTML o...
I have a variable $link_item, it's used with echo and gives the strings like <span class="name">Google</span>http://google.com How to remove "<span class="name">Google</span>" from string? It should give just "http://google.com". Heard it can be done with regex(), please help. ...
Hi All, I write a mysql query select * from table where name like '%salil%' which works fine but it will no return records with name 'sal-il', 'sa@lil'. So i want a query something like below select * from table whereremove_special_character_from(name)like '%salil%' remove_special_character_from(name) is a mysql method or a regul...
Hey, I'm using the code below to highlight some keywords in a text: $message = str_ireplace($words,'<span class="hightlighted_text">'.$words.'</span>',$message); The text may contain some html tags, for example , etc.. How can I highlight "normal" text, except the text between the html tags? Because when users search for "img" the ...
I have array which values are user input like: aa df rrr5 4323 54 hjy 10 gj @fgf %d Now I want to check each value in array to see whether it's numeric, alphabetic (a-zA-Z), or alphanumeric and save them in other respective arrays. I have done: my @num; my @char; my @alphanum; my $str =<>; my @temp = split(" ",$str); fore...
i have following code that strip all tags. now i want to strip only anchor tags. x = re.compile(r'<[^<]*?/?>') how to modify so that only anchor tags stripped. ...
my string style like this expression1/field1+expression2*expression3+expression4/field2*expression5*expression6/field3 a real style mybe like this: computer/(100)+web*mail+explorer/(200)*bbs*solution/(300) "+" and "*" represent operator "computer","web"...represent expression (100),(200) represent field num . field num may not exi...
Hello, I am trying to match information stored in a variable. I have a list of uuid's and ip addresses beside them. The code I have is: r = re.compile(r'urn:uuid:5EEF382F-JSQ9-3c45-D5E0-K15X8M8K76') m = r.match(str(serv)) if m1: print'Found' The string serv contains is: urn:uuid:7FDS890A-KD9E-3h53-G7E8-BHJSD6789D:[u'http://10.1...
Suppose we have this html content, and we are willing to get Content1, Content2,.. with regular expression. <li>Content1</li> <li>Content2</li> <li>Content3</li> <li>Content4</li> If I use the line below preg_match_all('/<li>(.*)<\/li>/', $text, $result); i will get an array with a single row containing: Content1</li> <li>Content2...
Good afternoon, I'm learning about using RegEx's in Ruby, and have hit a point where I need some assistance. I am trying to extract 0 to many URLs from a string. This is the code I'm using: sStrings = ["hello world: http://www.google.com", "There is only one url in this string http://yahoo.com . Did you get that?", "The first URL in t...
Hi I have a list of calling codes for all countries(the phone number prefixes), I would like to split them up in the country name and the actual code so I can put then into an xml. I have tried back and forth but can not get a regexp going that takes all cases into account. I think it is fairly simple for someone with a bit of experie...
Hi, I'm pretty sure this is some stupid mistake from me but i haven't been able to debug where the error in this lies. I'm trying to change image paths in html file with this regexp. It should work, but preg_replace is just returning null time after time. preg_replace("(src=){1}([\"']){1}(.*)([\/]+)(.*[\"']{1})", '/my/path'.$5 , $sour...
Do any of you know of an easy/clean way to find a substring within a string while ignoring some specified characters to find it. I think an example would explain things better: string: "Hello, -this- is a string" substring to find: "Hello this" chars to ignore: "," and "-" found the substring, result: "Hello, -this" Using Regex is no...
Hello everybody, I'm trying to get all words inside a string using Boost::regex in C++. Here's my input : "Hello there | network - bla bla hoho" using this code : regex rgx("[a-z]+",boost::regex::perl|boost::regex::icase); regex_search(input, result, rgx); for(unsigned int j=0; j<result.size(); ++j) ...
Hello, I'm using boost library to match substrings in a text. to iterate over results i need to use regex_iterator (see http://www.boost.org/doc/libs/1_42_0/libs/regex/doc/html/boost_regex/ref/regex_iterator.html) that's the only usage example i have found, but it's not clear for me (i don't understand the callback). could someone fa...
My codes is like pattern = 'arrayname[1]'; // fetch from dom, make literal here just for example reg = new RegExp(RegExp.quote(pattern), 'g'); mystring.replace(reg, 'arrayname[2]'); But it just cannot get running with error message says: "RegExp.quote is not a function", am i missing something simple? ...
Is it possible, using regex, to parse the query string and build a nice URL that can be translated back to the ugly URL for use on a legacy application? For example, let's say we are not certain what query string parameters are going to be part of a URL. Here is an example: http://www.domain.com/thePage.aspx?Param1=1&Param2=23&P...