Skip to content
Advertisement

Tag: regex

Regex to find content of the last occurence of square brackets

Hi Everybody, I’m Currently using preg_match and I’m trying to extract some informations enclosed in square brackets. So far, I have used this: /[(.*)]/ But I want it to be only the content of the last occurence – or the first one, if starting from the end! In the following: string = “Some text here [value_a] some more text [value_b]”

How to search in an array with preg_match?

How do I search in an array with preg_match? Example: Answer In this post I’ll provide you with three different methods of doing what you ask for. I actually recommend using the last snippet, since it’s easiest to comprehend as well as being quite neat in code. How do I see what elements in an array that matches my regular

Regular expression matching for entire string

I’m very new to PHP. I need to check whether a given string has characters from a given set, say {a, b, c}. So, I am trying regular expressions. “(abc)+” should do the trick. However, looking at the manual entries for preg_match and associated functions, I noticed that these functions perform sub-string matching instead of matching the entire string with

New line to paragraph function

I have this interesting function that I’m using to create new lines into paragraphs. I’m using it instead of the nl2br() function, as it outputs better formatted text. } The problem is that whenever I try to create a single line break, it inadvertently removes the first character of the paragraph below it. I’m not familiar enough with regex to

Split string on non-alphanumeric characters and on positions between digits and non-digits

I’m trying to split a string by non-alphanumeric delimiting characters AND between alternations of digits and non-digits. The end result should be a flat array of consisting of alphabetic strings and numeric strings. I’m working in PHP, and would like to use REGEX. Examples: ES-3810/24MX should become [‘ES’, ‘3810’, ’24’, ‘MX’] CISCO1538M should become [‘CISCO’ , ‘1538’, ‘M’] The input

scrape data using regex and simplehtmldom

i am trying to scrape some data from this site : http://laperuanavegana.wordpress.com/ . actually i want the title of recipe and ingredients . ingredients is located inside two specific keyword . i am trying to get this data using regex and simplehtmldom . but its showing the full html text not just the ingredients . here is my code :

Replace spaces around hyphens with nbsp

I’m in need of (probably) regexp (or two) to do following: replace every space after any single letter word with   I found this question, however, if there’s word with apostrophe (like there’s), previous regexp ‘thinks’ that the ‘s’ after the apostrophe is single letter (which is not right). I want/need the space ONLY after single letter, not any other

PHP: Regex match string not preceeded by a dollar sign

In my syntax highlighter, I use regex to parse different terms. Below is how I parse PHP classes: Now, just ignore the PHP class and the _getHtmlCode function. The regex, “/b{$class}b/”, matches names such as count. If I make a variable named $count, it matches that was well. How can I look for class names that are not preceded by

Advertisement