473,700 Members | 2,549 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 13770
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
17813
by: threepins | last post by:
Hi, Trying the following ... function getCurrentVal(poValue) { var lcCurrentVal = 0; if (isNaN(parseInt(poValue))) { var loValue = poValue.toUpperCase();
2
7205
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 for drinking black or with
18
7328
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; var req; var url = "http://mkmxg00/cgi/confirmUpload.pl";
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
5715
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 limitations to string lenght that will be evaluated by eval()?
2
3116
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", "link2.htm","link3.htm"); /* Resolve the location */ var loc=String(this.location);
1
5952
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
1425
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 ConnectionString mStringSQL ="INSERT INTO driver_destroyed_log ( emp_id, date_recieved, violation,...
0
8731
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8649
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9081
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
8975
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7819
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5904
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
4660
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2032
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.