preg-match Questions

6

I try to get phone numbers from string in german format. But I don't get it to full run. The input text is a full HTML-Page with lots of content, not only the numbers. Possible Formats: (06442) 3...
Rabon asked 8/1, 2017 at 22:28

10

Solved

I'm trying to search a UTF8-encoded string using preg_match. preg_match('/H/u', "\xC2\xA1Hola!", $a_matches, PREG_OFFSET_CAPTURE); echo $a_matches[0][1]; This should print 1, since &quot...
Phosphorate asked 12/11, 2009 at 20:40

4

Solved

I've got a string that contains UUID v4 $uuid = 'http://domain.com/images/123/b85066fc-248f-4ea9-b13d-0858dbf4efc1_small.jpg'; How would i get the b85066fc-248f-4ea9-b13d-0858dbf4efc1 value fro...
Anthozoan asked 3/6, 2011 at 5:8

6

Solved

I need to check a string to determine if it contains any characters other than |, in order to assign those variables that have nothing except | a value of NULL (there could be theoretically any num...
Joannejoannes asked 20/4, 2012 at 14:23

8

I have this code : $string1 = "My name is 'Kate' and im fine"; $pattern = "My name is '(.*)' and im fine"; preg_match($pattern , $string1, $matches); echo $matches[1]; and when im run it retur...
Flashover asked 5/10, 2011 at 11:25

5

Solved

Is there a good way of test if a string is a regex or normal string in PHP? Ideally I want to write a function to run a string through, that returns true or false. I had a look at preg_last_error...
Tahiti asked 28/5, 2012 at 0:50

13

Solved

How would I go about splitting the word: oneTwoThreeFour into an array so that I can get: one Two Three Four with preg_match ? I tired this but it just gives the whole word $words = preg_ma...
Ochlophobia asked 23/12, 2010 at 14:44

4

Solved

In PHP if we need to match a something like, ["one","two","three"], we could use the following regular expression with preg_match. $pattern = "/\[\"(\w+)\",\"(\w+)\",\"(\w+)\"\]/" By using the p...
Narrate asked 1/10, 2010 at 18:38

6

Solved

How do I search in an array with preg_match? Example: <?php if( preg_match( '/(my\n+string\n+)/i' , array( 'file' , 'my string => name', 'this') , $match) ) { //Excelent!! $items[] = $mat...
Presidium asked 24/12, 2011 at 23:1

8

Solved

I wrote a regex for php function pregmatch which is like this: ^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$^ Now I need to check the consistency of an BIC string. Something is...
Synodic asked 10/4, 2013 at 7:51

3

Solved

I have some strings which can be in the following format: sometext moretext 01 text text sometext moretext 002 text text 1 (somemoretext) etc I want to split these strings into following: text be...
Margy asked 15/1, 2013 at 22:23

3

Solved

I need to create an expression matching a whole number followed by either "seconds" or "minutes" I tried this expression: ([0-9]+)\s+(\bseconds\b)|(\bminutes\b) It works fine fo...
Coccyx asked 18/6, 2013 at 10:30

7

Solved

I want a solution to validate only domain names not full URLs, The following example is what I'm looking for: example.com -> true example.net -> true example.org -> true example.biz -> ...
Nicolle asked 12/6, 2010 at 0:0

12

Solved

This isn't a big issue for me (as far as I'm aware), it's more of something that's interested me. But what is the main difference, if any, of using is_numeric over preg_match (or vice versa) to val...
Norrisnorrv asked 4/10, 2011 at 14:48

8

Solved

$str = "This is a string"; $words = explode(" ", $str); Works fine, but spaces still go into array: $words === array ('This', 'is', 'a', '', '', '', 'string');//true I would prefer to have wor...
Glaciology asked 5/9, 2013 at 14:15

4

Solved

Can anyone give me a quick summary of the differences please? To my mind, are they both doing the same thing?
Bloem asked 9/3, 2011 at 12:6

9

Solved

The function below is designed to apply rel="nofollow" attributes to all external links and no internal links unless the path matches a predefined root URL defined as $my_folder below. So given th...
Loveinidleness asked 18/2, 2011 at 4:24

5

Thank you in advance for you time in helping with this issue.. preg_match(): Compilation failed: invalid range in character class at offset 20 session.php on line 278 This stopped working all...
Toon asked 15/7, 2014 at 17:11

7

Solved

I need some help with php regex, I want to "split" email address "[email protected]" to "johndoe" and "@example.com" Until now I have this: preg_match('/<?([^<]+?)@/', '[email prot...
Orthogenetic asked 27/7, 2011 at 20:36

7

Solved

im trying to validate a date to see if it matchs the mysql format this is the code $match = "/^\d{4}-\d{2}-\d{2} [0-2][0-3]:[0-5][0-9]:[0-5][0-9]$/"; $s = $this->input->post("report_star...
Amero asked 28/2, 2011 at 17:10

1

Solved

Any ideas why this preg_match works up to PHP7.2 but fails with 7.3+ ? $word = 'umweltfreundilch'; //real life example :/ preg_match('/^(?U)(.*(?:[aeiouyäöü])(?:[^aeiouyäöü]))(?X)(.*)$/u', $word, $...
Parthinia asked 10/9, 2020 at 8:51

5

Solved

I want to check whether a string is a file name (name DOT ext) or not. Name of file cannot contain / ? * : ; { } \ Could you please suggest me the regex expression to use in preg_match()?
Anglian asked 23/6, 2009 at 11:56

9

Solved

From an email address like [email protected] I want to fetch domain name gmail.com. i want to use that pattern on textbox value in Javascript. Pease suggest me an optimized and faster preg pa...
Snowdrop asked 3/3, 2011 at 14:5

7

Solved

I am writing a PHP script that accepts a regular expression pattern from the user which is used by preg_match(). How can I check that the pattern is valid?
Activity asked 14/9, 2010 at 15:39

6

Solved

I've been coding in PHP for a while and I keep reading that you should only use preg_match and preg_replace when you have to because it slows down performance. Why is this? Would it really be bad t...
Attendance asked 15/1, 2013 at 16:39

© 2022 - 2025 — McMap. All rights reserved.