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

S

Smart

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.
 
H

Hal Rosser

Smart said:
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

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.
}
 
H

Hal Rosser

Hal Rosser said:
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.
}

I think it will also work in javascript - what a co-inky-dink
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top