Ask a Question related to PHP Development, Design and Development.
-
Albert #1
PHP regular expressions
Hello,
I am writing an elearning software with php. I need a script to
recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
Could anyone tell me how can I do this using regular expressions?
Regards,
Albert Achtenberg
Albert Guest
-
RE : RE : Regular expressions
I think I begin to understand... I begin by fetching the results of the ps -efA command and split it into many variables ($uid, $pid, etc.) ... -
[PHP] Q on Regular Expressions
* Thus wrote jsWalter (jsWalter@torres.ws): have you looked at strtotime()? http://php.net/strtotime The Date formats it can find are defined... -
[PHP-DEV] PHP regular expressions
Hello. In regex/utils.h there is a definition for DUPMAX: #ifdef _POSIX2_RE_DUP_MAX #define DUPMAX _POSIX2_RE_DUP_MAX #else #define DUPMAX 255... -
Help with regular expressions.
Apples and Oranges: I think your format string is wrong, try: {0:d} "Pablo Pecora" <pablo.pecora@itau.com.ar> wrote in message... -
help with regular expressions
Hello, just getting grips with Perl and RE, but need your help. I am trying to open a file, print its contents to a textbox, but extract... -
Daniel Tryba #2
Re: PHP regular expressions
Albert <albert@arbel-designs.com> wrote:
So basically you need a regexp tutorial. I don't know any but studing> I am writing an elearning software with php. I need a script to
> recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
> Could anyone tell me how can I do this using regular expressions?
[url]http://nl.php.net/manual/en/pcre.pattern.syntax.php[/url] might help.
But what you want is trivial:
/a+b+/
a+ means: 'a' one or more times.
a+b+ means: 'a' one or more times followed by 'b' one or more times.
--
Daniel Tryba
Daniel Tryba Guest
-
Brian #3
Re: PHP regular expressions
[url]http://us2.php.net/manual/en/ref.pcre.php[/url]
"Albert" <albert@arbel-designs.com> wrote in message
news:748f323.0310280847.20d8ae91@posting.google.co m...> Hello,
>
> I am writing an elearning software with php. I need a script to
> recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
> Could anyone tell me how can I do this using regular expressions?
>
> Regards,
> Albert Achtenberg
Brian Guest
-
David Gillen #4
Re: PHP regular expressions
An noise sounding like Daniel Tryba said:
His problem was trivial, unfortunately you weren't able to see what he> Albert <albert@arbel-designs.com> wrote:>>> I am writing an elearning software with php. I need a script to
>> recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
>> Could anyone tell me how can I do this using regular expressions?
> So basically you need a regexp tutorial. I don't know any but studing
> [url]http://nl.php.net/manual/en/pcre.pattern.syntax.php[/url] might help.
>
> But what you want is trivial:
>
> /a+b+/
>
> a+ means: 'a' one or more times.
> a+b+ means: 'a' one or more times followed by 'b' one or more times.
>
required. The solution isn't quite as trivial.
Your solution would allow something along the lines of abbbb. What was asked
for was the same number of a's and b's.
db
--
I'm a dead man, and buggered to boot!
David Gillen Guest
-
CC Zona #5
Re: PHP regular expressions
In article <slrnbptabt.gh9.Belial@carbon.redbrick.dcu.ie>,
David Gillen <Belial@RedBrick.DCU.IE> wrote:
Yes, he needs a *script* to accomplish that. It doesn't sound like there's> An noise sounding like Daniel Tryba said:> His problem was trivial, unfortunately you weren't able to see what he> > Albert <albert@arbel-designs.com> wrote:> >> >> I am writing an elearning software with php. I need a script to
> >> recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
> >> Could anyone tell me how can I do this using regular expressions?
> > So basically you need a regexp tutorial. I don't know any but studing
> > [url]http://nl.php.net/manual/en/pcre.pattern.syntax.php[/url] might help.
> >
> > But what you want is trivial:
> >
> > /a+b+/
> >
> > a+ means: 'a' one or more times.
> > a+b+ means: 'a' one or more times followed by 'b' one or more times.
> >
> required. The solution isn't quite as trivial.
> Your solution would allow something along the lines of abbbb. What was asked
> for was the same number of a's and b's.
any requirement for the entire solution to be contained within the
regex[*]. A capturing regex takes care of the script's first step. Then
the script can easily be finished with a strlen operation.
Daniel, see [url]http://php.net/pcre.pattern.syntax[/url] and [url]http://php.net/strlen[/url] for more info.
* Though if there were such an arbitrary requirement, one could do the
length check within the callback function for preg_replace_callback and
then return a boolean as the replace value. A silly workaround, but one
that arguably meets such a requirement...
--
CC
CC Zona Guest
-
André Nęss #6
Re: PHP regular expressions
Albert:
In general you can't, regular expressions are not powerful enough to deal> I am writing an elearning software with php. I need a script to
> recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
> Could anyone tell me how can I do this using regular expressions?
with expression of the type A^nB^n. But there are of course ways to do what
you want. If you describe the actual problem in more detail we might be
able to help.
André Nęss
André Nęss Guest
-
Daniel Tryba #7
Re: PHP regular expressions
David Gillen <Belial@redbrick.dcu.ie> wrote:
Lets call it selective dyslecia. Scanning a line with aaaabbbb in it, to> His problem was trivial, unfortunately you weren't able to see what he>>>>> I am writing an elearning software with php. I need a script to
>>> recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
>>> Could anyone tell me how can I do this using regular expressions?
>> /a+b+/
>>
> required. The solution isn't quite as trivial.
> Your solution would allow something along the lines of abbbb. What was asked
> for was the same number of a's and b's.
me there appear to be more b's than a's.
But I should have read the question better..
--
Daniel Tryba
Daniel Tryba Guest
-
R. Rajesh Jeba Anbiah #8
Re: PHP regular expressions
[email]albert@arbel-designs.com[/email] (Albert) wrote in message news:<748f323.0310280847.20d8ae91@posting.google.c om>...
> Hello,
>
> I am writing an elearning software with php. I need a script to
> recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.
$str = "aabb";
if (preg_match("/(a+)(b+)/", $str, $matches) &&
(strlen($matches[1])==strlen($matches[2])))
echo 'match!';
***Try this [url]http://weitz.de/regex-coach[/url]
---
"Our songs have meaning for everyone. I don't know of anyone who
isn't either in love, just out of love, or else wants to be in
love."--- Graham Russell, Air Supply
Email: rrjanbiah-at-Y!com
R. Rajesh Jeba Anbiah Guest
-
Brian #9
Re: PHP regular expressions
> ***Try this [url]http://weitz.de/regex-coach[/url]
THis one is squarely focused on PHP.
[url]http://www.phpedit.net/products/RegExpEditor/[/url]
Brian Guest
-
Albert #10
Re: PHP regular expressions
Hi,
Thank you for your replies. In fact I was curious to see the replies
to my post as what I described is simply impossible. The explanation
is that reular expressions can only describe regular languages,
whereas {a^nb^n | n=0,1,...} is not a regular language (As one of the
replies stated).
I'm very sorry if someone was offened by this.
Thank you all,
Albert Achtenberg
Albert Guest



Reply With Quote

