Two Laptop Bag
The moose likes Java in General and the fly likes text processing Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "text processing " Watch "text processing " New topic
Author

text processing

Usama Rashwan
Ranch Hand

Joined: Oct 10, 2001
Posts: 33
i need to make a text processing and using function like Regular expression found in java script for example if i have a line like this
<img align="left" src="/img/i.gif">
or
<IMG align="left" src="/img/i.gif">
or
<IMG src="/img/i.gif" align="left">
i need to convert it to
<img align="left" src="http://localhost/img/i.gif">
so it should be not case sensetive . i can do that with javascript Regular expression but i don't know how to do that with java


SCJP2, SCWCD , SCEA Part I<br />Enterprise Application Development with IBM WebSphere Studio, V5.0<br />IBM Certified Solution Developer - WebSphere Studio, V5.0<br />IBM 483 (Enterprise Connectivity with J2EE)<br />IBM Certified Specialist - IBM WebSphere Application Server, Advanced Single Server Edition for Multiplatforms, V4.0
rudolf hitler
Ranch Hand

Joined: Feb 07, 2003
Posts: 34
Hi
There are 2 ways to perform the text processing out here one is you use this package called
com.stevesoft.pat at http://www.javaregex.com/ install it in ur jdk and then you can use the regex
or the second thin tht you can do is
use the lastIndexof() function to find the last index of "= "and ">"and extract everytin between them using substring that will give u your url then concatenate whtever u want to it and regenerate the entire <img> tag again.
Hope this helps.Let me know if it was of any help.Cya
Usama Rashwan
Ranch Hand

Joined: Oct 10, 2001
Posts: 33
i deciede to use ParserDelegator to parse the html file and change the value of the attribute that i need to change and i manged to do that but i don't know how to write the new values to a new html file
here is example of what i do
HTMLEditorKit.ParserCallback callback =
new HTMLEditorKit.ParserCallback () {
public void handleText(char[] data, int pos) {
System.out.println(data);
}
};
Reader reader = new FileReader("myFile.html");
new ParserDelegator().parse(reader, callback, false);
i need to write the new html to file
 
 
subject: text processing
 
Threads others viewed
Print Multiple Lines with out.write
Questions for webdesigner -developer experts! help!
should I be using ajax or just generate with javascript?
My bean doesn't quite work
cursor place i text field ????
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture