Skip to main content

Questions tagged [preg-match]

Regular expression pattern matching function for the PHP programming language

preg-match
0 votes
0 answers
24 views

preg_replace: get keys from short tags [field id="key"] and replace them with values [duplicate]

I have to determine all short tags like [field id="key1"] in the string, get the keys from the short tags to use them to get the values like $fields["key1"], then replace in the ...
Sevi's user avatar
  • 913
0 votes
1 answer
75 views

Skip Lazy Loading by Image Class Added to Figure Element in WordPress

This is how images are output in WordPress: <figure class="no-lazy"><img loading="lazy" class="wp-image-12345" src="apple.jpg" alt="apple">...
Wanderlust Consulting's user avatar
1 vote
0 answers
47 views

Trying to use preg_match for single word or no spaces, to combat spam

I have a form I continue to build on, so that I can keep spam from being sent through. So far, pretty good - in that the only thing now still getting through are single groups of random letters. I ...
HWL1223's user avatar
  • 21
0 votes
1 answer
49 views

Changing from file_get_contents to curl

I've been using file_get_contents in php until the last month when it's stopped working. So I've tried using curl but I'm now getting errors when I extract data from the downloaded webpage (finance....
Chris Appleby's user avatar
0 votes
1 answer
37 views

how can I use preg match to match several strings?

I wrote a preg_match to block spam in my form comments that works fine (this blocks web page URL insertion and 2 phrases, and throws a message, which also stops the send.): $error_message = "&...
HWL1223's user avatar
  • 21
2 votes
2 answers
54 views

PHP - Issue matching in string with preg_match

I have a string that contains a list of comma separated values. eg: $sitelist = 'SC001rug,SC002nw,SC003nrge'; I'm using preg_match to check if a site is in this string and then return the characters ...
Tom's user avatar
  • 1,560
-1 votes
1 answer
66 views

Detect any unwanted characters and number of lines in a file using PHP

I have a problem I can't resolve. And I can't have any feedback since I can only run the script directly on a server, without any possible debug. My files are transfered through FTP to a server and I ...
Laurent's user avatar
  • 160
0 votes
3 answers
117 views

PHP allow all accented characters in person name, but don't allow Chinese/Russian characters

I am having issues with allowing all English/Latin based characters (including accents), but disallowing Chinese/Russian characters. The first version I had was as follows: strlen($values['person_name'...
CopperRabbit's user avatar
0 votes
1 answer
41 views

How do I use preg_match() to extract words marked with ## from a string and then put them in html tag(s)?

How to get from here: The #quick# brown fox jumps over the #lazy# dog to here: The span-tag quick /span-tag brown fox jumps over the span-tag lazy /span-tag dog ? And sometimes it`s only: The quick ...
Wortuoso's user avatar
0 votes
1 answer
115 views

PHP preg_match page/1 in URL to redirect main URL with RegEx rules

I am creating php pagination and I want to matching the /page/1 in URL "/product-category/womens-jackets/page/1" If the /page/1 in matched then redirect it to the main URL "/product-...
Amir's user avatar
  • 33
1 vote
1 answer
57 views

preg_match input validation exemption

I have a preg_match function and I want to block 'MT', but allow 'PMT'. How would I amend this to work as it's picking up the MT in PMT at the moment? Thanks! function wppbc_custom_input_validation($...
Claschy's user avatar
  • 11
0 votes
1 answer
50 views

Implementing a PHP Router with Optional Parameters

I've been working on implementing a simple PHP router and have managed to make it work with required parameters. However, I'm struggling to implement optional parameters but I failed. I'll provide the ...
Omar Abdulwahhab's user avatar
0 votes
0 answers
30 views

How to preg_match regex values between dynamic urls in php [duplicate]

I want to preg_match the values between these html tags with php but the url is dynamic in these html elements it is change every time <a class='feedlink' target='_blank' href='https://www.hostname....
smallbee's user avatar
  • 351
1 vote
2 answers
57 views

How do I regex just the title out?

Sample text: 1. Medium Size +CA $33.00 2. Small Size -CA $4.00 I would like the result to be just 'Medium Size' or 'Small Size' using preg_match So the regex should detect the '-' or '+' sign and ...
Joshua Loo's user avatar
1 vote
1 answer
39 views

How to capture repeating information with regex

I try to capture all information in a string but only the last one is captured. I start with regex and i need some help. The string : correspondent à l'ASIN B00WU8XXXX, mais les attributs suivants ...
Maxime DANJOU's user avatar

15 30 50 per page
1
2 3 4 5
358