$Regex Data Capture Help
#270567
27/07/22 11:04 AM
|
Joined: Jan 2021
Posts: 7
BraveHeart73
OP
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
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?
|
|
|
Re: $Regex Data Capture Help
[Re: BraveHeart73]
#270570
27/07/22 09:46 PM
|
Joined: Jul 2006
Posts: 3,930
Wims
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 3,930 |
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
|
|
|
Re: $Regex Data Capture Help
[Re: Wims]
#270575
28/07/22 08:29 PM
|
Joined: Jan 2021
Posts: 7
BraveHeart73
OP
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
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.
|
|
|
Re: $Regex Data Capture Help
[Re: BraveHeart73]
#270576
28/07/22 09:21 PM
|
Joined: Jul 2006
Posts: 3,930
Wims
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 3,930 |
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
|
|
|
Re: $Regex Data Capture Help
[Re: Wims]
#270581
29/07/22 12:09 PM
|
Joined: Jan 2021
Posts: 7
BraveHeart73
OP
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
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
??
|
|
|
Re: $Regex Data Capture Help
[Re: BraveHeart73]
#270585
29/07/22 03:55 PM
|
Joined: Jul 2006
Posts: 3,930
Wims
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 3,930 |
Use the code provided in the post, all of it. not 92% of it.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
Re: $Regex Data Capture Help
[Re: BraveHeart73]
#270586
29/07/22 05:11 PM
|
Joined: Jul 2006
Posts: 3,930
Wims
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 3,930 |
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. 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
|
|
|
Re: $Regex Data Capture Help
[Re: Wims]
#270587
29/07/22 09:12 PM
|
Joined: Jan 2021
Posts: 7
BraveHeart73
OP
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
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.
|
|
|
Re: $Regex Data Capture Help
[Re: BraveHeart73]
#270588
30/07/22 01:05 AM
|
Joined: Jul 2006
Posts: 3,930
Wims
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 3,930 |
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
|
|
|
|
|