mIRC Home    About    Download    Register    News    Help

Print Thread
$regsubex marker suggestion #180881 14/07/07 08:34 PM
Joined: Apr 2007
Posts: 8
O
oliverw92 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
O
Joined: Apr 2007
Posts: 8
the other day i was trying to make something to remove duplicate letters in words

e.g. hello would turn to helo, elle would turn into el etc.

however i was having to do it a very long way. my suggestions is the \p special marker, which returns "previously substituted text".

example:

$regsubex(elle,/(.)/g,$iif(\1 !isin \p,\1))

would return el

$regsubex(extreme,/(.)/g,$iif(\1 !isin \p,\1))

would return extrm

i dont know whether \p is already in use in regex, if not, antoher letter. i have a feeling this could be very useful. thanks for ur time, hope this gets added!

Re: $regsubex marker suggestion [Re: oliverw92] #180888 14/07/07 09:49 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
If by "previously substituted text" you mean a string of all $iif(\1 !isin \p,\1)'s up to that step (ie a string of all newly encountered \1's), I agree, it could be useful.

Meanwhile, your specific problem can be solved with something like this:
//echo -ag $regsubex(extreme,/(.)/g,$iif(!$pos($left(\A,\n),\1,2),\1))

If you just want to keep unique letters, and not each first unique letter, you can also do this:
//echo -ag $regsubex(extreme,/(.)(?=.*\1)/g,)

Another imo useful marker would be an incremental equivalent of \A, ie a marker being the string of captured substrings up to the \n-th iteration

Last edited by qwerty; 15/07/07 12:00 AM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: $regsubex marker suggestion [Re: qwerty] #180918 15/07/07 12:24 AM
Joined: Apr 2007
Posts: 8
O
oliverw92 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
O
Joined: Apr 2007
Posts: 8
ah another good idea. and thanks for the help in that. i had something similar but it was it overly complicated.

Last edited by oliverw92; 15/07/07 12:30 AM.
Re: $regsubex marker suggestion [Re: qwerty] #180949 15/07/07 04:12 PM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Damnit qwerty you just spoilered the method i had set a challenge around. Although it can be shorter smile

Anyhow i support both suggestions.


$maybe
Re: $regsubex marker suggestion [Re: Mpdreamz] #180959 15/07/07 06:56 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
It can be shortened indeed (not sure if that's what you had in mind, ie if I further ruined your challenge :P)

//echo -ag $regsubex(extreme,/(.)/g,$iif($pos(\A,\1) == \n,\1))

It's not only shorter but more intuitive and slightly faster. Funny how often the simplest solutions are the last to come to mind.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: $regsubex marker suggestion [Re: qwerty] #180987 16/07/07 08:09 AM
Joined: Apr 2007
Posts: 8
O
oliverw92 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
O
Joined: Apr 2007
Posts: 8
whast the likely hood of this being accepted?

Re: $regsubex marker suggestion [Re: oliverw92] #181106 17/07/07 06:20 PM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
I previously suggested \A and that got added so who knows smile
It would rock though smile


$maybe