Skip to content

Tag: regex

php DOMDocument preg_replace fail detect

Basically, I want to replace content with hyperlink when detected matching keyword tag. the replace need to be outside of caption/image/figure/figcaption/iframe/a of existing content, because putting hyperlink inside these will causing format breaking. my php Now I facing 2 issue want to exclude replace hyperlink tag into but it fail on regex.. currently it display like this… this DOMDocument loadHTML

Decomposing a string into words separared by spaces, ignoring spaces within quoted strings, and considering ( and ) as words

How can I explode the following string: into I would like to extend the boolean fulltext search SQL query, adding the feature to specify specific columns using the notation column:value or column:”valueA value B”. How can I do this using preg_match_all($regexp, $query, $result), i.e., what is the correct regular expression to use? Or more generally, what would be the most

PHP preg_match not working as Input pattern

So I have this input pattern in HTML: <input name=”firstnamereg” type=”text” pattern=”[/p{L}+/u ]+”> But When I use the preg_match it does not work: $regexFirstANDLastname = “/[/p{L}+/u ]+/”; preg_match($regexFirstANDLastname, $_POST[“firstnamereg”]); Answer You need to use This pattern, in Chrome and Firefox, will be compiles as a new RegExp(“^(?:[\p{L}\s]+)$”, “u”) regex object. The u flag is used by default, you do not

str_contains returns true, but preg_match returns false

I am getting the HTML code of this website – with this code $html = file_get_contents($url) and then I am running a simple regex which does not work and I have no idea why. This code output – FALSE and this code output – TRUE Do you know where it could be the reason I checked the HTML several

Finding all 1 digit and 2 digits numbers in a larger number using regex

I want to match all 1 digit and 2 digit numbers using regex. Subject string: ‘12345’ Expected match: 1,2,3,4,5,12,23,34,45 I’m trying: d(d)? but as result i get 12,2,34,3,5 Answer You can use See the PHP demo. Output: NOTES: (?=((d)d?)) – a regex that captures into Group 1 two or one digits, and into Group 2 the first digit of the