Replace Characters between ( and )

What I want to do is simple, but acheiving it isn't proving as simple as I wanted.
I am by no means an expert with Javascript, quite the opposite in fact.

I have a string of text (which varies each time it is used), which will be displayed like

(text here) more text here, (text here) more text here ...etc...

The string could have 1 set of "(text here) more text here)" or a number of them, up to 27 maximum.

What I want to do is replace/remove from the string, everything between the "(" and ")", including the "(" and ")", just to leave the "more text here".

Any ideas.

Thanks
LVL 4
Answering4uAntAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZylochCommented:
This may need to be tweaked, but please see the following for inspiration.


<html>
<head>
<script type="text/javascript">

var str = "(text here) more text here, (text here) more text here";
var newstr = str.replace(/\(.*?\)\s*/g, "");
alert(newstr);

</script>
</head>
<body>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leakim971PluritechnicianCommented:
Hello Answering4uAnt,

A solution without regex :


<html>
<head>
<script type="text/javascript">

var str = "(text here) more text here, (text here) more text here";
var newstr = str.substr( str.indexOf("(") + 1, str.lastIndexOf(")")-1 );
alert(newstr);

</script>
</head>
<body>
</body>
</html>

Open in new window

0
RajeshpolaCommented:
http://tecfa.unige.ch/guides/js/ex-intro/angus_strings.html please use this site, u can write the Reg EXP for the above requirement.
0
Answering4uAntAuthor Commented:
perfect
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.