473,763 Members | 9,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to dinamically change the string in a find statement?

I have a script that opens a small window containing a button which
when clicked performs a find to the next occurence of a string. It
works well when the string is made of only one word or of consecutive
words.
Now I want it to find the next occurence of one of the words contained
in a list, ie. I want to dynamically change the string to find.
I failed to use a regular expression instead of a string in the find
statement.
Any idea of how I can do that?
Thanks.
Jul 23 '05 #1
4 1437
Yv************* ****@bull.net (Yves-Alain NICOLLET) wrote in message news:<72******* *************** ****@posting.go ogle.com>...
I have a script that opens a small window containing a button which
when clicked performs a find to the next occurence of a string. It
works well when the string is made of only one word or of consecutive
words.
Now I want it to find the next occurence of one of the words contained
in a list, ie. I want to dynamically change the string to find.
I failed to use a regular expression instead of a string in the find
statement.
Any idea of how I can do that?
Thanks.


To make myself clearer, is there a way to say:

find(a_word OR another_word OR yet_another_wor d OR etc) ?
Jul 23 '05 #2
Yves-Alain NICOLLET wrote:
Yv************* ****@bull.net (Yves-Alain NICOLLET) wrote in message
news:<72******* *************** ****@posting.go ogle.com>...


Please do not write attribution novels.
I have a script that opens a small window containing a button
Note the security restrictions for the window size:

http://devedge.netscap e.com/manuals/2000/javascript/1.3/reference/window.html#120 2731>
[...] Now I want it to find the next occurence of one of
the words contained in a list, ie. I want to dynamically change the
string to find. I failed to use a regular expression instead of a
string in the find statement. Any idea of how I can do that? Thanks.


To make myself clearer, is there a way to say:

find(a_word OR another_word OR yet_another_wor d OR etc) ?


Depends. There is the proprietary window.find() method which
returns `true' if unsuccessful, `false' otherwise. So you can
do consecutive searches:

function findWords()
{
var t;
if ((t = typeof window.find) == "function"
|| (t == object && window.find != null))
{
for (var i = 0, len = arguments.lengt h; i < len; i++)
{
var s = arguments[i];
if (window.find(s) )
{
return true; // or s if you like
}
}
}

return false; // no match
}

if (!findWords("a_ word", "another_wo rd", "yet_another_wo rd", "etc"))
{
alert("No match for either"
+ "'a_word', 'another_word', 'yet_another_wo rd' or 'etc'");
}

If you want two or more words to be matched and to be selected at
the same time, you need to parse the documents content. Dirty
proprietary quickhack:

document.body.i nnerHTML.replac e(
/(a_word|another _word|yet_anoth er_word|etc)/g,
'<span style="backgrou nd-color:yellow; color:black">$1 </span>');
HTH

PointedEars
Jul 23 '05 #3
Thomas 'Ingrid' Lahn wrote:
[...] There is the proprietary window.find() method which
returns `true' if unsuccessful, `false' otherwise. [...]


returns `true' if successful, `false' otherwise. [...]
PointedEars
Jul 23 '05 #4
Thomas 'Ingrid' Lahn wrote:
If you want two or more words to be matched and to be selected at
the same time, you need to parse the documents content. Dirty
proprietary quickhack:

document.body.i nnerHTML.replac e(
/(a_word|another _word|yet_anoth er_word|etc)/g,
'<span style="backgrou nd-color:yellow; color:black">$1 </span>');


This changes nothing really and "must be" "of course"[1]

document.body.i nnerHTML = document.body.i nnerHTML.replac e(
/(a_word|another _word|yet_anoth er_word|etc)/g,
'<span style="backgrou nd-color:yellow; color:black">$1 </span>');
PointedEars
___________
[1] Note it is still an evil quickhack.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2635
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an QA tested for a new year release. I don't think that going to prove practical, but there is no harm in trying :) and some serious family commitments. But it has to be done soon so this is stage one. Mike Winter provided an extensive list of...
2
1468
by: Daniel | last post by:
Hello!!! I'm creating controls dinamically in ASP.NET using VB. The problem is that i don't know how to catch the event of each button that i've create (the buttons are created dinamically). Any ideas?? Thanks!!!
2
12941
by: Marco | last post by:
How I can create TextBox dinamically. I have to create 10 textbox dinamically which name will be txtBox_01, txtBox_02, etc... Thanks.
2
1439
by: Fabio Cavassini | last post by:
I have this code that load HTML tags (no including <html> or <body>) into a DIV dinamically... after correctly retrieving the HTML, I assign it to my DIV Container document.getElementById(containerid).innerHTML=page_request.responseText now from main page....I need to get a reference to an Object (a textbox) contained in the dinamically loaded HTML
32
2676
by: Mateo | last post by:
I have char *array and it is dinamically alocated.... When I pass it to other function, I need to determine size of this array.... Problem: sizeof operator does not work with dinamically alocated arrays!?!?! How can I determine size of dinamically alocated array.... ? Please advice... Thx!
3
2681
by: valerio | last post by:
Hello all I would like to dinamically allocate an array of array of structures. To explain this: struct file{ char* fileName,int inode) myfiles; struct file{ char* fileName,int inode) mydirs; but I would like to do it dinamically with linked list. I am able to do it for myfiles, but not with mydirs. Pseudo-code is ok.
0
868
by: Chepre | last post by:
Hi, I've the following problem. I load an assembly dinamically through code, but I can't call the method GetCredentials correctly, it's allways null. Assembly assem = Assembly.LoadFrom(@"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\Microsoft.SharePoint.Portal.SingleSignon.dll"); Type typCred = assem.GetType("Microsoft.SharePoint.Portal.SingleSignon.Credentials"); System.Type arrTypes = new System.Type;...
0
916
by: DiegoBernini | last post by:
I have two assembly written in Managed C++ (VS2005) CdWrapperApi.dll, "contains" namespace CDWrapperApi { ... public interface class ICDProxy { public:
5
1072
by: srcp | last post by:
I got a table with for example 10 fields, field001, field002 ...field010 what i want is do something like this For i As Integer = 1 To 10 (table.field00 & i).value = "XX" Next i any ideas??
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.