473,387 Members | 1,574 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,387 software developers and data experts.

Regular expression hell

I've got this string:
Anonymous Login=False;Certificate Validation=ValidateAndAsk;Connect Timeout=60;Connection=Scriptor FTP;Download Folder=C:\Temp;Download Libraries=True;Email Address=email@address.com;Host CCSID=37;List Formats=OS/400 QSYS.LIB;Maximum Simultaneous Transfers=4;Network Address=www.address.com;Network Port=21;NLV=2924;Passive=True;Password=***;Receive Timeout=60;Send Timeout=60;Transfer Options=7;Use Encryption for Data=False;User ID=scriptor

I want to extract the value of "Download Folder". Namely, "C:\temp". I used to be a wiz at this stuff on Unix, but with Javascript I'm missing something. Here's my code:

var s;
var re = new RegExp("/Download Folder=([^;])/g");
var str = App.GetValue("connectionString");
var arr = re.exec(str);

s = str + "\n" + "$1 contains: " + RegExp.$1 + "\n";
s += "$2 contains: " + RegExp.$2 + "\n";
s += "$3 contains: " + RegExp.$3;

I always get zilch. I've tried all kinds of variations I can come up with for the RegExp() pattern; searched the web and tried differing syntaxes. BTW, 'str' is my string above. Got a headache from this; I think I'll go lie down a while. :-)

Thanks!
Mar 16 '07 #1
2 1250
Logician
210 100+
I've got this string:
Anonymous Login=False;Certificate Validation=ValidateAndAsk;Connect Timeout=60;Connection=Scriptor FTP;Download Folder=C:\Temp;Download Libraries=True;Email Address=email@address.com;Host CCSID=37;List Formats=OS/400 QSYS.LIB;Maximum Simultaneous Transfers=4;Network Address=www.address.com;Network Port=21;NLV=2924;Passive=True;Password=***;Receive Timeout=60;Send Timeout=60;Transfer Options=7;Use Encryption for Data=False;User ID=scriptor

I want to extract the value of "Download Folder". Namely, "C:\temp".
If str is your string:
Expand|Select|Wrap|Line Numbers
  1. alert( str.match(/Download Folder=([^;]+);/i)[1] )
  2.  
  3. // or
  4.  
  5. alert( str.match( new RegExp("Download Folder=([^;]+);","i"))[1] )
  6.  
This will produce "C:Temp" because the '\' is interpreted as the start of an escape sequence. If you need to fix this, you can get the initial string formatted differently as C:\\Temp or C:/Temp or insert / or \ after : if it's missing. It all depends upon what the host system/software can handle.
Mar 17 '07 #2
Worked like a champ. Much thanks for sure!
Mar 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tom | last post by:
I have struggled with the issue of whether or not to use Regular Expressions for a long time now, and after implementing many text manipulating solutions both ways, I've found that writing...
3
by: christopher diggins | last post by:
There seems to be a gazillion regular expression libraries. Most of them only work on text, but I wanted something that also worked on arbitrary sequences of data ( this is useful, for instance, in...
6
by: Jeff | last post by:
Hi, I'm finishing up developing a speech control jukebox (see intelligentjukebox.com) Can anyone point me to the easiest to use free library that does very basic regular expression matching...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
0
by: peter stickney | last post by:
Excuse the babbling or lack of sense, it's been a long day. I am making a flat file, static HTML search engine for a site. I downloaded a script from the net and have been working with it for my...
6
by: Jeff | last post by:
I always have trouble with javascript regexes... I want to parse apart a string and remember the matches and use them elswhere. Say I have: var test_string='one_two-three'; In perl I...
18
by: davranfor | last post by:
Hello I need a regular expression that validate a list of numbers separated by "-" , numbers can not be greater than 999 Valid examples 0 12-455-01 1-9
12
by: FAQEditor | last post by:
Anybody have any URL's to tutorials and/or references for Regular Expressions? The four I have so far are: http://docs.sun.com/source/816-6408-10/regexp.htm...
9
by: Kirk | last post by:
Hi All, the following regular expression matching seems to enter in a infinite loop: ################ import re text = ' MSX INTERNATIONAL HOLDINGS ITALIA srl (di seguito MSX ITALIA) una '...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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,...
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.