473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

ereg and me again ;)

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 1813
.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 alone

So ? 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
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
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 "<pre>\n" . print_r($number, true) . "</pre>";
-- END OF CODE -- CUT HERE --
Aphrael <ap*****@isuisse.com> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stefan Gangefors | last post by:
I'm trying to figure out what I'm doing wrong when using ereg(). This is my regexp: ereg("^]$", "]"); and that does'n work, but this does: ereg("^$", "[");
9
by: Fiore Alessandro | last post by:
Hi all I've installed Apache 2.0.48 and PHP 4.3.4 on a workstation running Linux, RedHat 9.0. Let's consider the following piece of code: $patt = "{3}/{6}"; if...
3
by: Martin Lucas-Smith | last post by:
Is there some way of using ereg to detect when certain filename extensions are supplied and to return false if so, WITHOUT using the ! operator before ereg () ? I have an API that allows as an...
3
by: Rafal Zak | last post by:
I have a little problem with ereg (eregi) in PHP - in some cases it behaves differently than I expect and I don`t know if my expectations are strange or there is any "syntax subtlety" I have...
3
by: Dynamo | last post by:
Hi, Thanks to all who replied to original posting.As a direct result of now gaining a better understanding of regular expressions, instead of trying to use other peoples scripts I am now trying to...
3
by: news | last post by:
I'm trying to make sure a form has only one or two digits in either of two fields. I looked at php.net and http://www.regular-expressions.info/reference.html and this is what I put together, but...
18
by: yawnmoth | last post by:
Say I have the following script: <? $string = 'test'; if (eregi("^+$",$string)) { echo 'matches!'; } else {
6
by: Cerebral Believer | last post by:
Is this a good ereg statement? if (!ereg("^+(\.+)*@+(\.{1,})*\.({2,}){1}$",$email_1 or $email_2)) { unset($_GET); $message_new = "<font color='#cc0000'>$email_1 or $email_2 is not a valid...
2
by: dkirkdrei | last post by:
I am having a problem verifying characters in a variable, I am trying to create a conditional statement based on whether or not the first two characters of a variable contain "E9". The variable...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.