Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

regexp on eg.event.string

If you have a question or need help, this is the place to be.
Post Reply
User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

regexp on eg.event.string

Post by Fiasco »

I have an event where the value is passed after the final decimal. How can I grab that with a regexp and pass it to a action?

Broadcast.volumelevel.45
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: regexp on eg.event.string

Post by jinxdone »

Well.. the simplest way is to use plain string split to split it into an array, no need to use regexp for something simple like this

Code: Select all

print('Broadcast.volumelevel.45'.split('.'))
# prints an array ['Broadcast', 'volumelevel', '45']
If you wanted you could do it with regexp with something like..

Code: Select all

import re
r = re.search('[^\.]+?$', 'Broadcast.volumelevel.45')
print(r.group(0))
# prints the string '45'.
regexp is really useful though, not only in python but everywhere in programming, so I really recommend learning it to everybody. http://www.regular-expressions.info/ is a good site for reading up on it.

-jinxdone
Post Reply