Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ Regular Expression help
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Strazor
USA (24 posts) Bio
|
| Date
| Tue 26 Aug 2014 05:44 PM (UTC) Amended on Tue 26 Aug 2014 05:46 PM (UTC) by Strazor
|
| Message
| I'm brand new to regular expressions. I've read http://www.gammon.com.au/mushclient/regexp.htm and I'm having trouble visualizing what I need. How can I ignore the white space and simplify this to not worry about spacing?
<trigger
enabled="y"
match="^\| Type \: (.*?) Level \: (.*?) \|$"
regexp="y"
script="capture_type_level"
>
</trigger>
I am extracting the data from the "ID pearl" command on aardwolf. Here is an example.
+-----------------------------------------------------------------+
| Keywords : 41neck openstock touchstone pearl Asura |
| Name : (>Asura's Azurite Pearl<) |
| Id : 965751006 |
| Worn : Neck |
| Type : Armor Level : 41 |
| Worth : 5,060 Weight : 0 |
| Wearable : neck |
| Score : 185 |
| Material : pearl |
| Flags : unique, glow, hum, magic, held, burn-proof, |
| : solidified, illuminated, V3 |
| Notes : This item is from a clan hall. |
| Notes : Item has 2 resistance affects. |
+-----------------------------------------------------------------+
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Tue 26 Aug 2014 07:37 PM (UTC) |
| Message
| Use \s+ to match one or more spaces.
<triggers>
<trigger
enabled="y"
match="^\| Type\s+\: (\w+)\s+Level\s+\:\s+(\d+)\s+\|$"
regexp="y"
send_to="12"
sequence="100"
>
<send>
Note ("Type = %1")
Note ("Level = %2")
</send>
</trigger>
</triggers>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
Also if you know you are expecting digits you can use \d+ (one ore more digits). The above worked on your test data. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Strazor
USA (24 posts) Bio
|
| Date
| Reply #2 on Tue 26 Aug 2014 08:35 PM (UTC) |
| Message
| | Thank you Nick. Very helpful. | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
14,961 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top