Using preg_replace to reformat money amounts in text with PHP

I’m struggling with some regular expressions. What I want to do is find money amounts in a string, remove the €,$, or £ but keep the number, and then look to see if there is a ‘b’ or an ‘m’ – in which …

PHP- Recursive Regex to get complete Div Class with it’s inner content

I have searched but cannot find a solution that works. I have tried using DOM but the result is not identical (different spaces and tag elements – minor differences but I need identical for further …

Using preg_replace_callback to find and replace a function signature with a variable number of parameters

Using the PHP preg_replace_callback function, I want to replace the occurrences of the pattern “function([x1,x2])” with substring “X1X2”, “function([x1,x2,x3])” with …

Java Regex vs. PHP, Dangling meta character ‘?’

I’m tagging this with PHP even though it’s a Java question. The regex is copied from a PHP source so I’m hoping some PHPers can help with the question. I decided to build a simple spam filter, just …

Regex to extract (austrian) street housenumber/stairs/floor/door

I need to extract the housenumber with all the different constellations in austria: | Street name | housenumber | stairs | floor | door | | ———————————…

How to exclude single-lettered title case words in a string?

I have a database table that stores wishes from users. From that, I’d like to extract any title case words that they have submitted. I was able to obtain this output, however it includes single-…

php: check if a variable has/lacks particular characters

I actually have two questions but they are almost the same thing. no1, I want to use PHP to check if a variable contains anything that is not a forward slash or a number, I am aware that I can use …

Get index of first dot with letter in a string

I have a string like this one: dsl-34.345.324-24718.pool.vodafone9.com (not a real hostname, just an example) I’ve already tinkered around with preg_split which didn’t gave me the good result. Anyway, …

PHP – Password RegEx requirements

I am trying to validate if a new user account’s password is matching these criterias: Between 8-30 characters long Contains at least 1 lowercase letter (a-z) Contains at least 1 uppercase letter (A-Z)…

Regex: how to add a capture group?

I currently have this regex: [(?:w+*?s+)?([^][]+)] I want to add another capture group, so I can capture the text value before the groups. For example: Je naam (verplicht) [text* your-test] …