mIRC Home    About    Download    Register    News    Help

Print Thread
#270567 27/07/22 11:04 AM
Joined: Jan 2021
Posts: 7
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2021
Posts: 7
Hi.
I want to capture data with @ & and ~ symbols in it. I made some attempts but no results.

//echo -a $regsubex(@Gandalf %Legolas @Brave,/\[@&~]/g,\1) = Return : @Gandalf @Brave : OK very good.

For example, there is no problem with this first command
-----
However, when there is a name with no symbols, the regex catches it as well. :S

Sample: //echo -a $regsubex(@Gandalf Legolas BraveHeart @Brave,/\[@&~]/g,\1) : Return: @Gandalf Legolas BraveHeart @Brave

Whereas it should only give names containing @, & and ~.


In short, how can I catch names containing @, & and ~ symbols with regex?

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Hey,

$regsubex(@Gandalf %Legolas @Brave,/\[@&~]/g,\1) removes "%legolas" because it's a variable name and it evaluates to $null, not because of the regex you're doing. your expression /\[@&~]/g is invalid and result in mIRC returning the original input string, and you're using \1 but your expression has no capturing group in the expression with (), so it doesn't make sense anyway.

Your second example is all the same, except there's no variable, so the original input string is returned.

If you want to 'remove' token seperated by space in the input string, you would use a pattern such as /(?<=^| )[@&~][^ ]+(?=$| )/g, $regsubex(@a c @a d @a,/(?<=^| )[@&~][^ ]+(?=$| )/g,) returns "c d"


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2021
Posts: 7
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2021
Posts: 7
@Wim'ler Thank you for the answer.

However, it was the opposite of what I wanted. Maybe we had a communication problem because my English is not enough.

What I want is to display the parts with @ & % ~ .

So regex command response ;

$regsubex(@a b %c d @e f, > Return : @a %c @e I want it this way.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
If you pass %c manually to regsubex it's evaluated, for the test you need to get %c plain text with % $+ c for example.

You can use the following pattern to achieve what you want: $regsubex(@a @r b &u i o % $+ c d @e f ~g ,/(?:((?:^| )[@~&%][^ ]+(?=$| ))|(?: |^)[^ ]+(?= |$))/gF,\1\2)

Last edited by Wims; 28/07/22 11:05 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2021
Posts: 7
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2021
Posts: 7
Thank you for the answer.


echo -a $regsubex(@a @r b &u i o d @e f ~g ,/(?:((?:^| )[@~&][^ ]+(?=$| ))|(?: |^)[^ ]+(?= |$))/gF,\1) : Return : @a @r &u &u @e @e @e @e ~g ~g

shows the same characters more than once :S

it should have been like this: Return : @a @r &u @e ~g

??

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Use the code provided in the post, all of it. not 92% of it.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Hum, in fact you only missed the \2 from the replacement.. and that \2 came from an earlier solution, it's not required anymore in the current solution, but having it is not a problem and will work the same, so it should have worked for you.
Quote
echo -a $regsubex(@a @r b &u i o d @e f ~g ,/(?:((?:^| )[@~&][^ ]+(?=$| ))|(?: |^)[^ ]+(?= |$))/gF,\1) : Return : @a @r &u &u @e @e @e @e ~g ~g
This returns the correct result, it does not return what you said, which version of mIRC are you using?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2021
Posts: 7
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2021
Posts: 7
Thank you for the answer.

mIRC version 6.35
-
It still shows the characters more than once unfortunately.

Last edited by BraveHeart73; 29/07/22 09:13 PM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
You get incorrect result because you're using 6.35. Here is a fix for 6.35:

//echo -a $regsubex(@a @r b &u i o d @e f ~g ,/(?:((?:^| )[@~&][^ ]+(?=$| ))|(?: |^)[^ ]+(?= |$))/g,\t)

The pattern js the same, you only replace \1 with \t (same as $regml(\n)).


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard