I'm trying to use regexmatches and I want to have pull groups pulled from the result. I'm aware that you can put these in groupings and with regexreplace you can replace values from the result but I'm wondering how can I just get the results from this list into something I can grab? For example, I'm trying:
$name = "abc-123";
$search = regexmatches($name, "^([a-z]+)(-)?([0-9]+)", ",");
Can I use something like
msg gettoken($search, "1");
to get a result?
Is there a way to use regexmatches and select a grouping?
-
- Posts: 31
- Joined: 19 Apr 2014 19:39
Re: Is there a way to use regexmatches and select a grouping
that would be a boon to have!
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Posts: 31
- Joined: 19 Apr 2014 19:39
Re: Is there a way to use regexmatches and select a grouping
Figured out a way. However, I was hoping for something cleaner. It will match but unfortunately you need to account for the whole string to match because it just replaces contents you find. Unmatched content is left intact:SammaySarkar wrote:that would be a boon to have!
$name = "abc-123";
$results = regexreplace($name, "^[\[\s]*([a-z]+)[-]?([0-9]+)", "$1|$2");
msg gettoken($results, "1", "|");
Re: Is there a way to use regexmatches and select a grouping
That doesn't use regexmatches (which you've asked for)
What are you trying to achieve here?
is enough.
What are you trying to achieve here?
Code: Select all
[\[\s]*
Code: Select all
\s*
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 31
- Joined: 19 Apr 2014 19:39
Re: Is there a way to use regexmatches and select a grouping
Sorry I use a brackets and space in my names ex. abc-123 to [ abc-123 ] to try and make them cleaner. I didn't specify it in my comment because I was trying to keep it simple. Then I was removing it from my example and forgot the beginning.highend wrote:That doesn't use regexmatches (which you've asked for)
What are you trying to achieve here?Code: Select all
[\[\s]*
is enough.Code: Select all
\s*