![]() |
|
|||||||
| SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
RegEX help
Okay trying to better understand regex and all its powers
First I am not a regex fan I realize how powerful it is but I suck at it to put it bluntly. I am using this site to try and help me along the way. I am looking for a way to build regex patters for typing on the remote to match all letters. Say the user pushes number 2 and number 3. I want it to match against [a,b,c] and [d,e,f] and return all possible matches/combination of the two. ie ad,ae,af,bd,be,bd,cd,ce,cf. I want to continue building this regex based on how many numbers they push. Sort of like smart texting. I thought I read sage did something similar in the advanced functions but I don't use those so if someone wants to point me in that direction that would be ok too. TIA |
|
#2
|
||||
|
||||
|
Phoenix has an API for that
![]() phoenix_util_CreateRegexFromKeyPad You feed it your keypad entry, and it will return a java regex. You could write your own, but I suggest depending on the phoenix-api and just use that one.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
|
#3
|
|||
|
|||
|
Quote:
![]() That doesn't do much for helping me learn , but none the less will work.Off to sneak a peak at the code
|
|
#4
|
|||
|
|||
|
In looking at your return I was so close...yet so far I as stupidly forgetting to put the CAPS versions in there...oh well just use your method as it is done
![]() cheers |
|
#5
|
||||
|
||||
|
RegEx's are lots of fun. For beginners I recommend Learning Perl from O'Reilly publishing. Its got a great section on RegEx basics and its a lot easier to play around with them in a scripting language like Perl rather than one that needs to be compiled like Java.
Those basics will get you pretty far, but if you really want to be one of the cool kids you can also upgrade to Regular Expression Pocket Reference from O'Reilly which will pretty much forge you into a RegEx ninja master, much like myself
__________________
Clients: 1xHD200 Connected to 50" TH-50PZ750U Plasma Server : Shuttle SFF SSH55J2 w/ Win7 Home, SageTV v7, Core i3 540, 2GB RAM, 30GB SSD for OS, 1.5TB+2x1TB WDGP for Recordings, BluRay, 2xHDHR, 1xFirewire SageTV : PlayOn, SJQ, MediaShrink, Comskip, Jetty, Web Client, BMT Having a problem? Don't forget to include a log! (Instructions for: PlayOn For SageTV v1.5, MediaShrink) |
|
#6
|
|||
|
|||
|
Quote:
|
|
#7
|
|||
|
|||
|
__________________
Host: ESXi 6.5 w/ Intel Core i7 2.8GHZ 8GB Ram Guest: Ubuntu 16.04 with Sage v9 in Docker Tuners: 2 HDHR (OTA); Extenders: HD300 connected to a Samsung 56" DLP HDTV; HD300 connected to a Sharp 42" LCD Storage: OmniOS w/6 1TB Samsung Spinpoint in a RaidZ2 configuration in a 20 bay SATA hotswap case. |
|
#8
|
||||
|
||||
|
$prevPost = s/dis/strongly /g;
See, we're having fun now!
__________________
Clients: 1xHD200 Connected to 50" TH-50PZ750U Plasma Server : Shuttle SFF SSH55J2 w/ Win7 Home, SageTV v7, Core i3 540, 2GB RAM, 30GB SSD for OS, 1.5TB+2x1TB WDGP for Recordings, BluRay, 2xHDHR, 1xFirewire SageTV : PlayOn, SJQ, MediaShrink, Comskip, Jetty, Web Client, BMT Having a problem? Don't forget to include a log! (Instructions for: PlayOn For SageTV v1.5, MediaShrink) |
|
#9
|
||||
|
||||
|
I have to admit, I was never a fan of regular expressions, but over the years, I've learned that they can be tremendously helpful, and even a time saver. As a developer, I've written my share of text processors, and when I look back, regex could have saved me hours and hours of work
![]() Just last week, I was working with a guy who had to process some data from an external source (web service), that happened to contain html code (that's just wrong). But he needed just the text, and not all the html tags. (the html was simple formatting for a description, that contained things like <b> and <i>, etc... ). He started talking about how he could write a processor that could find all the <tags>, and remove them... all in all, he figured no more than a couple of hrs work... I let him go on for a bit, explaining the process... then i got out a piece of paper and wrote on it.... text = text.replaceAll("<[^>]+>","") And I walked away... The thing is, regex has it's place. If you use it, for the right reasons, it will save your time. Now perl on the the other hand...
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
|
#10
|
|||
|
|||
|
The one problem I have had is their performance in Java. Even when you compile them and reuse, if you are doing simple text processing across a huge number of lines - they just can't keep up with a custom text processor. But that is to be expected.
Probably not going to be an issue with a sage plugin.
__________________
Host: ESXi 6.5 w/ Intel Core i7 2.8GHZ 8GB Ram Guest: Ubuntu 16.04 with Sage v9 in Docker Tuners: 2 HDHR (OTA); Extenders: HD300 connected to a Samsung 56" DLP HDTV; HD300 connected to a Sharp 42" LCD Storage: OmniOS w/6 1TB Samsung Spinpoint in a RaidZ2 configuration in a 20 bay SATA hotswap case. |
|
#11
|
|||
|
|||
|
Yeah I don't see a sagetv user having enough movies in their databse to really notice the speed that bad...I am actually running them in SQL queries and although not the most efficient I would think it would take way more of a database size than sagetv users have to notice it.
|
|
#12
|
|||
|
|||
|
If you are using them as filters, specially if you are going to have multiple filters - you may want to look at the Google Collections Iterable/Predicate filtering mechanism. I have found it very useful before when filtering data.
__________________
Host: ESXi 6.5 w/ Intel Core i7 2.8GHZ 8GB Ram Guest: Ubuntu 16.04 with Sage v9 in Docker Tuners: 2 HDHR (OTA); Extenders: HD300 connected to a Samsung 56" DLP HDTV; HD300 connected to a Sharp 42" LCD Storage: OmniOS w/6 1TB Samsung Spinpoint in a RaidZ2 configuration in a 20 bay SATA hotswap case. |
|
#13
|
|||
|
|||
|
Quote:
I know you don't need it anymore, but the Pattern/Matcher combination works pretty well. No need to specify the upper and lower case, since the flag will take care of it. Code:
String foo = "af";
Pattern pattern = Pattern.compile("[abc][def]", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(foo);
if (matcher.matches()) { doStuff(); }
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| parser regex question (replace?) | cornasdf | Batch Metadata Tools | 3 | 10-18-2010 07:43 AM |
| Regex help for tv shows | PLUCKYHD | Batch Metadata Tools | 4 | 05-23-2010 09:35 AM |
| RegEx for Favorites? | matterw | SageTV Software | 2 | 01-23-2010 11:47 PM |
| Regex in Favorites??? | zoundz | SageTV Software | 0 | 10-20-2008 10:56 AM |