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 …

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 (regex): Extract column names from SQL-Query

I am struggling with a regular expression in PHP: I have a number of SQL-queries. Now, I’d like to extract the variable names (column names) within these queries. It should return an array (…

Regex for FIGI numbers

I am trying to write some regex to match FIGI numbers. FIGI numbers have 12 characters and are built in the following structure: A two-letter prefix, excluding (BS, BM, GG, GB, GH, KY, VG) G as the …

PHP preg_replace: Replace All Hyphens in String That Appear Before the Last Hyphen w/ Space

Using preg_replace (or other PHP-based option): I need to replace all hyphens in a string, that appear before the last hyphen, with space. Example #1 of the Result I Need: string = My-Cool-String – …

Is there any option to separate special characters from words with regex/preg_split?

I’m junior and not at ease with regex, and I’m trying to do a password generator with sentences using regex and preg_split. All is done except one thing, for example the sentence “I’ve got 2 cats.” …