1

I spent hours trying to do it and still doesn't work. Even with other topic I can't find the solution.

This is the string :

S.C.V. Ch. Latour (Exploitante) Latour Château Latour 33250 PauillacCordonnées GPS : 45.175167 -0.749777Tél: 05 56 73 19 80Fax: 05 56 73 19 81Email: [email protected] web: http

And I'd like to get three things : the "Tél" number, the "Fax" number and the "Email".

2 Answers 2

2
/Tél: (.+)Fax: (.+)Email: (.+)Site/

There you go. The three submatches are your numbers.

Sign up to request clarification or add additional context in comments.

3 Comments

I dont get how to use your solution
preg_match_all('{{your regular expression}}', '{{your data}}', $arr, PREG_PATTERN_ORDER);
Note that you must use delimiters. I will add them for clearity.
1

If you are sure to have the same order (tél., fax, email, site) for each entry, you can use this:

$pattern = '~(?:Tél|Fax|Email): \K([\d ]++|.+?(?=Site web:))~';

3 Comments

Nop it's not working, preg_match('~(?:Tél|Fax|Email): \K([\d ]++|.+?(?=Site web:))~', $div->nodeValue, $data);echo 'Tel' . $data[0] . '<br/>'; echo 'Fax' . $data[1] . '<br/>';
@Cédric: normal, you must use preg_match_all, not preg_match
Its not working neither with preg_match_all, $data[0][0] or $data[1][0] display nothing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.