regexp help request thread

Message Bookmarked
Bookmark Removed
Not all messages are displayed: show all messages (10 of them)

ILX-code woes made me remove the bit where I set $, to \n for human-readable output; posted it and then realised I could just have used any character except curly braces after my qq

agrarian gamekeeper (a passing spacecadet), Sunday, 9 January 2011 22:26 (thirteen years ago) link

I think I misunderstood the % symbols!

a fucking stove just fell on my foot. (Colonel Poo), Sunday, 9 January 2011 23:14 (thirteen years ago) link

but yeah "%(.*?)%" works

a fucking stove just fell on my foot. (Colonel Poo), Sunday, 9 January 2011 23:20 (thirteen years ago) link

That works, but why doesn't "% are nice but %" count as a match?

Gravel Puzzleworth, Monday, 10 January 2011 00:27 (thirteen years ago) link

the bit in the middle u mean? because that % symbol ("% are ...") has already been matched in its "%cats%" incarnation.

iow "%(.*?)%" will match "%cats%", the processor will then go to work on the remaining part, "are nice but %strings% are stringy", and match "%strings%".

nanoflymo (ledge), Monday, 10 January 2011 09:47 (thirteen years ago) link

you can also "force non-greedy" with [^\n\r]*

progressive cuts (Tracer Hand), Monday, 17 January 2011 13:01 (thirteen years ago) link


You must be logged in to post. Please either login here, or if you are not registered, you may register here.