Questions tagged [preg-match-all]

A PHP function that performs a global regular expression match using PCRE patterns.

A PHP function that performs a global regular expression match using PCRE patterns.

int preg_match_all ( 
     string $pattern , 
     string $subject 
     [, array &$matches 
     [, int $flags = PREG_PATTERN_ORDER 
     [, int $offset = 0 ]]] 
)

preg_match_all() in the PHP Manual

1934 questions
0
votes
0 answers

PHP preg_match_all but not a exact match

I'm trying to create a list of game names and compare it to a website however the game name aren't always 100% the same text is there a way i can do a partial comparison ? This is the title on the…
Exoon
  • 1,513
  • 4
  • 20
  • 35
0
votes
2 answers

Preg_Match Error To Get Line

if(preg_match("//*/i",$line))echo "comment start"; if(preg_match("/*//i",$line))echo "comment end"; I'm searching comments which one starts with /* and end with */ and I cant get any result with this code. I’m trying to get comment start and end…
0
votes
1 answer

PHP: How to convert smart quotes to normal quotes when regex matching?

I have a small piece of code that searches a string for a pattern of text - The idea here being to find quotes within a string. Currently I have this as the preg_match function preg_match_all('/"([^"]+)"/', $essay, $q); However I have…
user2075625
  • 93
  • 2
  • 11
0
votes
1 answer

preg_match_all an array of items, then for each matches

I am editing some Interspire Email code. Currently the program goes through the HTML of the email before sending, and looks for 'a href' code, to replace the links. I want it to also go through and get form action="" and replace the urls in them …
brizz
  • 271
  • 1
  • 6
  • 17
0
votes
1 answer

Preg match all in bbcode using php 5.4 validation issue

I'm writing some php code in order to validate bbcode, I have no error but the bbcode won't validate my input... why? Something missing? //============================================================// // Check if all BBCode are validated before…
Alecos
  • 57
  • 2
  • 8
0
votes
3 answers

Identify phone number in a string

i am using the following code to detect if a string is a phone number...
asdf
  • 460
  • 1
  • 10
  • 31
0
votes
3 answers

PHP regex preg_match_all() between [[ and ]]

I would like to use preg_match_all() to extract the content between [[ and ]], but ignoring [[[ and ]]], so for example this text: $text = <<
user702300
  • 1,211
  • 5
  • 22
  • 32
0
votes
2 answers

Name of a href tag

I'm a complete newbie with regular expressions and I feel bad about it now, when I need some serious advice on how to extract a link name out of an ahref tag, ie. This article is cool and I would need to…
Sates
  • 408
  • 1
  • 5
  • 21
0
votes
3 answers

Regular expression to extract annotation parameter

i want to extract parameter like exist in annotation i have done this far $str = "(action=bla,arg=2,test=15,op)"; preg_match_all('/([^\(,]+)=([^,\)]*)/', $str, $m); $data = array_combine($m[1], $m[2]); var_dump($data); this gives following out…
Bhavik Patel
  • 789
  • 6
  • 20
0
votes
2 answers

Preg_Match_All and RegEx Getting Values

I'm trying to get the 2 values in this string using regex: a:2:{i:45;s:29:"Program Name 1";i:590;s:19:"Program Name 2";} There are 2 variables that start with "s:" and end with ":" which I am attempting to get from this string (and similar…
NotJay
  • 3,919
  • 5
  • 38
  • 62
0
votes
3 answers

php preg_match_all preg_replace array issue

I'm working on a bb-code replacement function when a user wants to post a smiley. The problem is, that if someone uses a bb-code smiley that doesn't exists, it results in an empty post because the browser will not display the (non-existing)…
lickmycode
  • 2,069
  • 2
  • 19
  • 20
0
votes
1 answer

PHP preg_match_all to get images with ?w= in last

I am trying to get image using preg_match_all but cant get it right here is my code. my problem i that i have soome images with .img ext and some with .jpg?w=655&h=357, i dont need .img but need all other valid images it can have ?w=655&h=357 in…
Harinder
  • 1,257
  • 8
  • 27
  • 54
0
votes
3 answers

PHP - Parsing String From HTML File

Hey guys I'm parsing a bunch of data from an html file in PHP using the preg_match_all($pattern, $htmlPage, $matches) method (regular expressions) and am having some issues creating the pattern for the following string:…
ScottOBot
  • 839
  • 3
  • 16
  • 37
0
votes
2 answers

Trouble with preg_match_all, regex, and /is

I am webscraping a HTML page using preg_match_all in PHP. This is what I'm trying to scrape: