|
-
Substring replacement on AttributedString
How can I replace a substring of an AttributedString with another string of characters? I have an application that allows the user to input text into a JTextPane and the text is then stored as an AttributedString. I'd like them to be able to type in something like "My name is %NAME%" and then be able to replace the characters %NAME% with a string from a database. I've been trying to use regular expressions to do this but the problem is that I need to be able to retain the character formatting. I can strip all the character attributes off and get String containing the characters of the AttributedString and then use a regx to replace the substring but then I have to put the attributes back on which is especially difficult if the length of the two substrings is different. i.e. %NAME% is 6 characters, Bob is 3. Any suggestions?
Similar Threads
-
Replies: 13
Last Post: 10-03-2007, 07:47 AM
-
Replies: 2
Last Post: 01-15-2006, 10:54 AM
-
By Alan Shiers in forum Java
Replies: 0
Last Post: 05-14-2001, 09:57 PM
-
By Doug in forum VB Classic
Replies: 3
Last Post: 04-05-2001, 12:33 PM
-
By Mehdi Mousavi in forum Database
Replies: 0
Last Post: 11-22-2000, 03:42 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks