455,713 Members | 1,267 Online
Need help? Post your question and get tips & solutions from a community of 455,713 IT Pros & Developers. It's quick & easy.

# ereg and me again ;)

 P: n/a Hello all, last time, ereg specialists did help me, so I ask again: base pattern: some texte her [a number between 1 and 100] result: the number alone So ? any idea ? Aphrael ;-) -- "La demande mondiale d’ordinateurs n’excédera pas cinq machines." (Thomas Watson, Fondateur d'IBM, 1945) Jul 17 '05 #1
3 Replies

 P: n/a .oO(Aphrael) last time, ereg specialists did help me, so I ask again:base pattern: some texte her [a number between 1 and 100]result: the number aloneSo ? any idea ? Assuming that I understood correctly - try if the following patterns work for you: for ereg(): '\[([0-9]+)]' for preg_match() (preferred, more flexible and faster in most cases): '#\[(\d+)]#' If that's not enough post some more examples and the expected results. HTH Micha Jul 17 '05 #2

 P: n/a Aphrael wrote: last time, ereg specialists did help me, so I ask again: Must it be ereg? Preg_* functions are better because they support PCREs. base pattern: some texte her [a number between 1 and 100] result: the number alone Between one and a hundred inclusive: `.*?\[([1-9]\d?|100)\]`s Anything is matched until a left square bracket. After that, either a digit between one and nine followed by an optional digit between zero and nine, or the number one hundred, is captured. Then a right square bracket is matched. The s pattern modifier makes the dot metacharacter match newlines. HAGS! -- Jock Jul 17 '05 #3

 P: n/a try this ereg: ([0-9]{1,2}|100) -- BEGIN OF CODE - CUT HERE -- \$delimiter = "\s"; preg_match("/\$delimiter([0-9]{1,2}|100)\$delimiter/", \$your_text, \$number); echo "
\n" . print_r(\$number, true) . "
"; -- END OF CODE -- CUT HERE -- Aphrael wrote in message news:<41**********@news.bluewin.ch>... Hello all, last time, ereg specialists did help me, so I ask again: base pattern: some texte her [a number between 1 and 100] result: the number alone So ? any idea ? Aphrael ;-) Jul 17 '05 #4

### This discussion thread is closed

Replies have been disabled for this discussion.