|
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
|
|||
|
|||
Easier way to insert character into String
Lets say I have a string consisting of numbers and letters that is 32 characters long. I want to insert a "-" every 2 spaces is there a quick and easy way to do this without looping?
|
#2
|
||||
|
||||
Not really. And any other function that you DID use would in turn do the looping in it, so it's not really a performance concern.
Well, I guess that's not entirely correct, if you KNOW the string is always 32 characters long, you could string together a long list of substrings: Substring(input,0,2) & "-" & Substring(input,2,2) & "-" & Substring(input,4,2)... etc...
__________________
Buy Fuzzy a beer! (Fuzzy likes beer) unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers. Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA. Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S Other Clients: Mi Box in Master Bedroom, HD-200 in kids room |
#3
|
||||
|
||||
Regular expressions make this pretty easy as long as you can find the right one I kept getting an extra dash at the end until I found the answer (the funny-looking '(?!$)' ) on this page.
Code:
"ABCDEFGH".replaceAll("(.{2})(?!$)", "$1-")
__________________
Server: Intel Core i5 760 Quad, Gigabyte GA-H57M-USB3, 4GB RAM, Gigabyte GeForce 210, 120GB SSD (OS), 1TB SATA, HD HomeRun. Extender: STP-HD300, Harmony 550 Remote, Netgear MCA1001 Ethernet over Coax. SageTV: SageTV Server 7.1.8 on Ubuntu Linux 11.04, SageTV Placeshifter for Mac 6.6.2, SageTV Client 7.0.15 for Windows, Linux Placeshifter 7.1.8 on Server and Client, Java 1.6. Plugins: Jetty, Nielm's Web Server, Mobile Web Interface. |
#4
|
|||
|
|||
Quote:
|
#5
|
||||
|
||||
They are powerful.. but damn i hate RegEx... ;-)
__________________
Buy Fuzzy a beer! (Fuzzy likes beer) unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers. Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA. Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S Other Clients: Mi Box in Master Bedroom, HD-200 in kids room |
#6
|
||||
|
||||
Yeah my original regex kept appending a dash at the end. It took me a while to find the magic '(?!$)' that prevented it. It's one of those "special constructs" in the Javadoc that I never understood until now.
__________________
Server: Intel Core i5 760 Quad, Gigabyte GA-H57M-USB3, 4GB RAM, Gigabyte GeForce 210, 120GB SSD (OS), 1TB SATA, HD HomeRun. Extender: STP-HD300, Harmony 550 Remote, Netgear MCA1001 Ethernet over Coax. SageTV: SageTV Server 7.1.8 on Ubuntu Linux 11.04, SageTV Placeshifter for Mac 6.6.2, SageTV Client 7.0.15 for Windows, Linux Placeshifter 7.1.8 on Server and Client, Java 1.6. Plugins: Jetty, Nielm's Web Server, Mobile Web Interface. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Non-english filename character support? | beatmania | SageTV HD Theater - Media Player | 1 | 06-08-2009 06:16 PM |
Central European Character problems | alanwww1 | SageTV Software | 0 | 12-15-2007 12:20 PM |
Unicode character support with MVP | Lucas | SageTV Media Extender | 0 | 01-10-2006 01:52 AM |
Interfacing with character LCDs | brandium | General Discussion | 2 | 01-17-2005 10:18 PM |
support of non-english character in Music Jukebox | sarudoshi2004 | SageTV Software | 3 | 10-14-2004 07:38 AM |