This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

TCL regexp limitation?

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

TCL regexp limitation?

Post by tomekk »

Hey,

Look at this:

Code: Select all

[tomekk@zonk]:/home# php -r 'echo preg_match("/^[a-z]{1,256}$/", "abcd") . "\n";'
1

Code: Select all

[tomekk@zonk]:/home# perl -e 'print "abcd" =~ /[a-z]{1,256}/ . "\n"'
1
tcl:

Code: Select all

[tomekk@zonk]:/home# echo "puts [regexp {^[a-z]{1,256}$} abcd]" | tclsh
couldn't compile regular expression pattern: invalid repetition count(s)

Code: Select all

[tomekk@zonk]:/home# echo "puts [regexp {^[a-z]{1,255}$} abcd]" | tclsh
1
Damn, don't tell me that I have to use [string length] instead of one nice regexp?
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

and as far as I know, theres no limitation of regex usage in tcl, havent had any problems at all yet.

//edit:

looks like max specified limit is working with 255 but not with 256 :/
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

yeah, I'm using TCL couple of years, but today is a first day when I used the range {1, 256} and I got this what I wrote above ;]
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

found this on the web:
RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255.
not really making sense if it works in php

... BUT, you are free to use

Code: Select all

puts [regexp {^[a-z]{1,}$} abcd]
which works in my case and limits between 1 and unlimited
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

raider2k wrote:found this on the web:
RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255.
not really making sense if it works in php

... BUT, you are free to use

Code: Select all

puts [regexp {^[a-z]{1,}$} abcd]
which works in my case and limits between 1 and unlimited
hehe, I know about that,
but I need to set a range,
otherwise its funny thing with that :)

without proper regexp I have to use extra [string length]
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

how about exec yourscript.php $var?

and besides that, I would wait for nml or someone else who might be knowing about such "issues" - I dont use limiters very often
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

raider2k wrote:how about exec yourscript.php $var?
oh no way, it's stupid ;p
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

lol
but its a much better solution than using more code, at least in my humbly opinion :P
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

I can always use couple of ranges, I mean (512 chars):

Code: Select all

[tomekk@zonk]:/home# echo "puts [regexp {^[a-z]{1,255}[a-z]{0,255}[a-z]{0,2}$} "<512 a chars in here>" ]" | tclsh
1
but this limitation is still funny ;)
Post Reply