Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Does anyone have a JAVA script that will search for a string within a string?

Thread view: 
Smart - 01 Feb 2006 03:30 GMT
Does anyone have a JAVA script that will search for a string within a
string within a text file or HTML file?

   Something that simulates this Basic language command:

INSTR (position, string1$,string2$)

if position>0 then string found

  Also, does anyone have a JAVA script file that will printout a
modified file based on the string found within a string.

----------------------------------------------
 Thank you.
Hal Rosser - 01 Feb 2006 05:10 GMT
> Does anyone have a JAVA script that will search for a string within a
> string within a text file or HTML file?
[quoted text clipped - 4 lines]
>
> if position>0 then string found

Try the indexOf method of the string.
Assume strHaystack is the string you're searching and strNeedle is the
string you're searching for:
if (strHaystack.indexOf(strNeedle) >= 0){
       //code if the string was found.
}
Hal Rosser - 01 Feb 2006 05:15 GMT
> > Does anyone have a JAVA script that will search for a string within a
> > string within a text file or HTML file?
[quoted text clipped - 11 lines]
>         //code if the string was found.
> }

I think it will also work in javascript - what a co-inky-dink
Roedy Green - 01 Feb 2006 10:46 GMT
>   Also, does anyone have a JAVA script file that will printout a
>modified file based on the string found within a string.

see http://mindprod.com/jgloss/javascript.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.