473,573 Members | 4,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error: unterminated parenthetical in RegExp

Today, I was trying to construct a regular express in JavaScript. But
I kept getting the "Error: unterminated parenthetical" message.

I want to do something like this:

keyCombo = ":(";
pattern = new RegExp (keyCombo);
str = string.replace (pattern, "frown");

So, first thing I fixed is ":\(" . . . But I still get the same error!
I've also tried ":\\\\(". And that didn't work. Please help and give
me a hint. Thanks.

Chieh
--
GearHack - http://www.GearHack.com/

Feb 2 '07 #1
2 13761
I want to do something like this:
>
keyCombo = ":(";
pattern = new RegExp (keyCombo);
str = string.replace (pattern, "frown");
Ok, I figured it out. It has to be surrounded by brackets to be
recognized as a character:

":[\(]"

Now I'm having another problem. "<3" isn't being recognized. It
doesn't error out. But none of the permutations work: "\<3", "[<]3",
and "[\<]3".

Quite weird . . . . there are so many exceptions to regular
expression. *sigh*

Chieh
--
GearHack - http://www.GearHack.com/

Feb 3 '07 #2
Lee
gy*******@yahoo .com said:
>
>I want to do something like this:

keyCombo = ":(";
pattern = new RegExp (keyCombo);
str = string.replace (pattern, "frown");

Ok, I figured it out. It has to be surrounded by brackets to be
recognized as a character:

":[\(]"

Now I'm having another problem. "<3" isn't being recognized. It
doesn't error out. But none of the permutations work: "\<3", "[<]3",
and "[\<]3".

Quite weird . . . . there are so many exceptions to regular
expression. *sigh*
Why are you going through strings to get a RegExp?
Try RegExp literals:

pattern=/:\(/;

What do you mean by "none of the permutations *work*"?

var pattern=/<3/;
alert("abc<3def ".replace(patte rn," "));
--

Feb 3 '07 #3

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

Similar topics

3
17809
by: threepins | last post by:
Hi, Trying the following ... function getCurrentVal(poValue) { var lcCurrentVal = 0; if (isNaN(parseInt(poValue))) { var loValue = poValue.toUpperCase();
2
7187
by: Daniel Secomb | last post by:
Hi, I'm using PostgreSQL 7.3.4 on phpPgAdmin 2.4.2 and I'm getting the following error when I try and run a SQL query on a script: Error - /usr/local/psa/admin/htdocs/domains/databases/phpPgAdmin/db_readdump.php -- Line: 33 PostgreSQL said: ERROR: parser: unterminated quoted string at or near "'Black Tea\015\012Fresh range of leaf tea...
18
7318
by: William | last post by:
I have the following javascript function that updates a scroll_list and sends the updated entry (with its index) to a server script ( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further processing: function saveText( scroll_list, t_area, listToBeUpdated ) { scroll_list.options.text = t_area.text; scroll_list.options.value= t_area.value;...
13
504
by: Bill | last post by:
Can someone help me with this error: error C2143: syntax error : missing ';' before 'type' Here is the line it's complaining about: for(int i=0;i<4;i++){ printf("%d",x); }
7
5701
basstradamus
by: basstradamus | last post by:
Hi When I am trying to eveluate object literal It causing Unterminated string constans error (firefox). var obiekt = (eval("("+data+")")); the data is carring object literal recived from server (AJAX - JSON format) It works normaly for smaller strings, but when data variable has about 20 000 chars there is an error. Is there any...
2
3108
by: rajuk | last post by:
Hi i have following code,when i execute this code i got unterminated string constant error.any javascript guru can you look into this please. raju /* The link details */ var links = new Array ("link1", "link2", "link3"); var links_text = new Array ("Link 1", "Link 2", "Link 3"); var links_url = new Array ("link1.htm",...
1
5944
by: VUNETdotUS | last post by:
Let's say I have a string: div.innerHTML = "<a onclick='foo(\""+myWord+"\");'></a>"; in IE only (tested version 7) if var myWord = "English" then it works fine but if var myWord = "Modifier Cha\u00EEnes" then I get "Unterminated string constant" error. What fix would you suggest to keep div.innerHTML = "" format?
14
1414
by: cptcanada | last post by:
I am trying to useSQL code inside VB code and I keep getting an Expected Case error on my first select statement, can any one help me with this?? Thanks ConnectionString = "Provider=SQLOLEDB.1;server=wsus;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=inv_tracking" set cn = CreateObject("ADODB.Connection") cn.Open...
0
7707
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8037
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. ...
0
8215
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...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6432
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5296
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...
0
3743
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1325
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1048
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...

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.