|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
For any Java programmers out there:
I need a way to cut the ^ characters and the character following the ^ and replace it with the correct HTML syntax. For example: Input: ^1=^3SWAT^1=^4DerKammisar Output: <font face="Arial" size="4" color="#FF0000">=</font><font face="Arial" size="4" color="#FFFF00">SWAT</font><font face="Arial" size="4" color="#FF0000">=</font><font face="Arial" size="4" color="#0000FF">DerKammisar</font> I've written some code that strips the items but not replaces it: PHP Code:
Thanks for the help in advance! |
|
#2
|
|||
|
|||
|
Personally, I would use regular expressions for this. you could use the String.replaceAll() method
replaceAll Tutorial |
|
#3
|
|||
|
|||
|
Oi, this is going to take a while... But thanks. I do appreciate it. However I ran into a problem, is there a way I can tell it to only replace the character following the ^ if it is an interger?
|
|
#4
|
|||
|
|||
|
Yes. There really is nothing that comes close to the power of regular expressions for text manipulation. You can be very precise on what you want replaced. you can replace all carats(^) only if they are followed by a digit and leave all other carats intact. If you plan on doing any serious programming in your life you will never regret learning regexs. If you need help when making them, post what you have here and I will help you.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Need help with character replacement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|