On Thu, 28 Aug 2003 15:50:49 +0200
"point" <point@caanNOSP AMproduction.co m> wrote:
[color=blue]
> I need some help with regulars...
>
> how can I check if $var contains only "----" (minus) no metter how
> many??
>
> Thanx...
>
> point[/color]
Don't cross post, it's considered bad form.
/^-+$/
Begining of the line (^), followed by minus (-) one or more times (+)
followed by end of line ($)
There are some very good online tutorial for regexs; try here
--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9631 7719 | this to be a coincidence. " www.quispiam.com | - Jeremy S. Anderson
On Thu, 28 Aug 2003 15:50:49 +0200 in
<message-id:bil19u01kqn@ enews1.newsguy. com>
"point" <point@caanNOSP AMproduction.co m> wrote:
[color=blue]
> I need some help with regulars...
>
> how can I check if $var contains only "----" (minus) no metter how
> many??
>
> Thanx...
>
> point
>
>[/color]
--
Ian.H [Design & Development]
digiServ Network - Web solutions www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
Programming, Web design, development & hosting.
On Thu, 28 Aug 2003 16:27:42 +0100 in
<message-id:2n7skvkk5rop m0gp5l25vsiqblr n8qebs3@4ax.com >
Andy Hassall <andy@andyh.co. uk> wrote:
[color=blue]
> On Thu, 28 Aug 2003 14:48:25 GMT, "Ian.H [dS]"
> <ian@WINDOZEdig iserv.net> wrote:
>[color=green]
> >preg_match('/^([-]+)$/', $var)[/color]
>
> Just a tip - don't capture unless you actually want to use the
> subexpressions,
> and there's no point having a character class of a single character.
>
> /^-+$/ is enough here.[/color]
Thanks Andy.. after I replied and re-synced the groups.. I noticed the
reply without the match / group chars.. I guess it's one of those things
where "I used it before.. it works..." and I haven't really got around
to try and improve it.
Good tip and noted.. especially as I use lots of regex for various
projects =)
Regards,
Ian
--
Ian.H [Design & Development]
digiServ Network - Web solutions www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
Programming, Web design, development & hosting.
point wrote:[color=blue]
>
> I need some help with regulars...
>
> how can I check if $var contains only "----" (minus) no metter how many??[/color]
Just as a point of interest, I compared the following 3 regular expressions:
/^-+$/, /[^-]/, /^([-]+)$/
I was going to suggest !preg_match("/[^-]/",$val), then realized it wouldn't
return false on an empty string, but I threw it in anyway. The code I used
follows the comparions. In just about ever case /^-+/ won. No surprised there,
just thought I find out how much different they are. I reordered the regex
array 3 times to make sure the array position wasn't biasing the results.
Shawn Wilson wrote:
[color=blue]
> Just as a point of interest, I compared the following 3 regular expressions:[/color]
<snip>
Wow. I reread my post and am embarrassed by the number of spelling and grammar
mistakes. In case anyone is wondering, English is my first language.
I forgott to say: Thanx guys :)))
"point" <point@caanNOSP AMproduction.co m> wrote in message
news:bil19u01kq n@enews1.newsgu y.com...[color=blue]
> I need some help with regulars...
>
> how can I check if $var contains only "----" (minus) no metter how many??
>
> Thanx...
>
> point
>
>[/color]
Comment