473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

RegExps in js

Hi all,

I have a function that produces a string within it with a root relative
path...

/mysite/images/

The problem is that this is being "seen" as a RegExp when processing it
further in the script. I really need this string to stay in this format. Is
there a way to make the script not see this as a RegExp?

Thanks, David
Jul 23 '05 #1
6 1201
> I have a function that produces a string within it with a root relative
path...

/mysite/images/ The problem is that this is being "seen" as a RegExp when processing it
further in the script. I really need this string to stay in this format.
Is there a way to make the script not see this as a RegExp?


Just in case more info is needed here is an example of how it is. One
function gets the var from an ASP query string. This function then contains
another function, named otherFunction() here, which prosesses this var.

function whatever(){
var theString='<%=Request.QueryString("cap")%>'
eval("otherFunction("+theString+")");
}

Hope this helps a bit.

David
Jul 23 '05 #2
Ivo
"David" <ri***@dd.com> wrote
I have a function that produces a string within it with a root relative
path...

/mysite/images/
The problem is that this is being "seen" as a RegExp when processing it
further in the script. I really need this string to stay in this format.
Is there a way to make the script not see this as a RegExp?


Just in case more info is needed here is an example of how it is. One
function gets the var from an ASP query string. This function then

contains another function, named otherFunction() here, which prosesses this var.

function whatever(){
var theString='<%=Request.QueryString("cap")%>'
eval("otherFunction("+theString+")");
}


Why are you using eval?

otherFunction( theString )

should really be enough. If you look closely to what you are passing the
eval, it *is* a RegExp! There are no quotes around theString, which is
needed to recognize an argument as a string. Here eval is used once more,
but this time with single quotes delimiting theString, and all inside the
double quotes:

eval("otherFunction( '"+theString+"' )");

hth
ivo
Jul 23 '05 #3


David wrote:

function whatever(){
var theString='<%=Request.QueryString("cap")%>'
eval("otherFunction("+theString+")");


Why can't you simply call
otherFunction(theString)
? That calls the function and passes in the string value. The only
problem seems to be that you call eval.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
function whatever(){
var theString='<%=Request.QueryString("cap")%>'
eval("otherFunction("+theString+")");


Why can't you simply call
otherFunction(theString)
? That calls the function and passes in the string value. The only problem
seems to be that you call eval.

--

Martin Honnen
http://JavaScript.FAQTs.com/



Jul 23 '05 #5
>> function whatever(){
var theString='<%=Request.QueryString("cap")%>'
eval("otherFunction("+theString+")");


Why can't you simply call
otherFunction(theString)
? That calls the function and passes in the string value. The only problem
seems to be that you call eval.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Either way I do it, it still sees it as a RegExp.

function whatever(){
var theString='<%=Request.QueryString("cap")%>'
eval("otherFunction("+theString+")");
}

****************************
function whatever(){
var theString='<%=Request.QueryString("cap")%>'
otherFunction(theString);
}




Jul 23 '05 #6
> Why are you using eval?

otherFunction( theString )

should really be enough. If you look closely to what you are passing the
eval, it *is* a RegExp! There are no quotes around theString, which is
needed to recognize an argument as a string. Here eval is used once more,
but this time with single quotes delimiting theString, and all inside the
double quotes:

eval("otherFunction( '"+theString+"' )");

hth
ivo

Wait, my bad.

Delimiting the args or eliminating the eval alltogether works.

Thanks guys :-)

David
Jul 23 '05 #7

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

Similar topics

2
by: Geoff Soper | last post by:
I'm trying to work out how to process a block of text which contains tags similar to http://something.com. I want to work through the text block and pass the contents of each tag to function and...
1
by: Florian Behaim | last post by:
Greetings, Say I got the following: A hash ($list) with the keys named keyA, keyB, ... and values associated to them (valueA, valueB). Furthermore a template with placeholders like {keyA}...
0
by: R. Tarazi | last post by:
Hello together, I'm having extreme difficulties using RegExps for a specific problem and would really appreciate any help and hope somebody will read through my "long" posting... 1. <?php...
5
by: Klaus Alexander Seistrup | last post by:
Hi, Is there a way to "expand" simple regexps? Something along the lines of: #v+ >>> rx = '(a|b)c?(d|f)' >>> expand_regexp(rx)
6
by: Kirk Strauser | last post by:
I'm writing a program to scan through a bunch of VB source.  An example of one of the types of strings I'm trying to match is:     response.write Request.Cookies ("domain")("cname") but I do...
4
by: Magnus Lie Hetland | last post by:
Hi! I've been looking at ways of dealing with nested structures in regexps (becuase I figured that would be faster than the Python parsing code I've currently got) and came across a few...
2
by: Fredrik Ramsberg | last post by:
When searching for a specific sequence of charcters, like ($text =~ /monkeybreath/), how efficient is Perl compared to other algorithms specifically developed for this purpose? Does Perl recognise...
4
by: Ken Fine | last post by:
I'd like my FSO script to act only on files that fit a pattern, files that include "icon" in the name. Below, I have FSO code that acts on files that begin with "icon" and have an extension of...
4
by: possibilitybox | last post by:
I'm trying to make a unicode friendly regexp to grab sentences reasonably reliably for as many unicode languages as possible, focusing on european languages first, hence it'd be useful to be able...
2
by: Yorian | last post by:
I just started to try regexps in php and I didn't have too many problems, however I found a few when trying to build a templte engine. The first one is found is the dollar sign. In my template I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.