Hi there!
I am a newbie in regular expressions with a very limited knowledge..
I wish to extract blocks of text from a column of a MyISAM MySQL Table.
The blocks always are build the same way or, if you prefer, with the same "pattern":
block, is :
- a first group of characters: upper or lowercase, spaces (always followed by a letter), some quotation marks and/or dashes but no numbers.
- a space always followed by a number (may be used as a kind of "delimiter" ??? between the two groups)
- a second group of characters: only numbers, always one and only one dash, sometimes an interrogation mark which could only be encountered after the dash never before the dash. There is no spaces and no letters in this second group.
Examples :
"L'Arbresle-sur-le-Lac 2345-6789"
or
"Saint-Denis l'Église 1234-?"
So, it will be useful for me to know how to write and use a regex which will be able to find them as a whole
I mean all the resulting variables as one string, as I show between quotation marks in the examples
I already wrote the following regex:
(([a-zA-Z][\-\É\é\è\.\(\)\'\s]+)( +)([0-9]+)-([0-9]+|\\?+))
(case insensitive)
It works in MySQL but doesn't give me the expected results.
I expected at least 5000 results but got a mere 900...
The query returns the whole content of the column instead of only the "blocks"
Here is the MySQL query:
SELECT ID, longName, notes
FROM `_a_listregex`
WHERE notes REGEXP '(([a-zA-Z][\-\É\é\è\.\(\)\'\s]+)( +)([0-9]+)-([0-9]+|\\?+))'
ORDER BY `ID`
How should I write it to make it return only the "blocks"?
This regex will be later used in a PHP script to manipulate the results.
I am not familiar at all with preg_xxxx and don't understand how to write my PHP query to use the regex...
:-(
Many thanks in advance for your help and/or advices
...and don't hesitate to ask for precisions if needed!!!