473,406 Members | 2,371 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,406 software developers and data experts.

RegExp for removing text between parenthesis

Hi,

I have a string like this:
GeboGebo Wiki 0.9.2 (Default branch)

I want to remove the words between the parenthesis. I tried this regexp:
/\([a-zA-Z0-9]\)/ but without success, what is wrong with it ?

Thank you,
--
Colossus

Cpsed, a Linux OpenGL 3D scene editor
http://cpsed.sourceforge.net/
Jul 17 '05 #1
5 7044
Colossus wrote:
I have a string like this:
GeboGebo Wiki 0.9.2 (Default branch)

I want to remove the words between the parenthesis. I tried this
regexp: /\([a-zA-Z0-9]\)/ but without success, what is wrong with it
?


You're looking for *exactly one* character a-z or 0-9.

RegExp /\([a-z0-9\ ]+\)/ might work a bit better. Though, it takes the
parenthesis with the contents, and I don't know if that's the wanted
behaviour (you said you wanted to remove the *text* between
parenthesis).

--
Markku Uttula

Jul 17 '05 #2
Markku Uttula wrote:
RegExp /\([a-z0-9\ ]+\)/ might work a bit better. Though, it takes the
parenthesis with the contents, and I don't know if that's the wanted
behaviour (you said you wanted to remove the *text* between parenthesis).


Thank you, i should also remove the parenthesis. How to do ?
--
Colossus

Cpsed, a Linux OpenGL 3D scene editor
http://cpsed.sourceforge.net/
Jul 17 '05 #3
Colossus wrote:
I have a string like this:
GeboGebo Wiki 0.9.2 (Default branch)

I want to remove the words between the parenthesis.
If your string is, as you say, like that, why not use the
string functions instead?

substr($subject,0,strpos($subject,'('))
I tried this regexp:
/\([a-zA-Z0-9]\)/ but without success, what is wrong with it ?


Your character class doesn't allow spaces and only matches a
single character and the surrounding brackets.

`\([a-z ]+\)`i

--
Jock
Jul 17 '05 #4
John Dunlop wrote:
Your character class doesn't allow spaces and only matches a
single character and the surrounding brackets.
`\([a-z ]+\)`i


Thank you, it works ! I don't know php; can the substr be used as a
replacement of the regexp `\([a-z ]+\)`i ? Which is faster ?
--
Colossus

Cpsed, a Linux OpenGL 3D scene editor
http://cpsed.sourceforge.net/
Jul 17 '05 #5
Colossus wrote:
can the substr be used as a replacement of the regexp `\([a-z ]+\)`i ?
The regular expression matches letters and spaces and the
surrounding brackets, whereas the substr returns everything
up to the first '('. The equivalence of their output
depends on your subject string.
Which is faster ?


I don't know. Can you tell me?

--
Jock
Jul 17 '05 #6

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

Similar topics

3
by: Jane Doe | last post by:
Hello, I need to browse a list of hyperlinks, each followed by an author, and remove the links only for certain authors. 1. I searched the archives on Google, but didn't find how to tell the...
4
by: McKirahan | last post by:
How would I use a regular expression to remove all trailing Carriage Returns and Line Feeds (%0D%0A) from a textarea's value? Thanks in advance. Also, are they any great references for learning...
0
by: Chris Croughton | last post by:
I'm trying to use the EXSLT regexp package from http://www.exslt.org/regexp/functions/match/index.html (specifically the match function) with the libxml xltproc (which supports EXSLT), but...
6
by: Christoph | last post by:
I'm trying to set up client side validation for a textarea form element to ensure that the data entered does not exceed 200 characters. I'm using the following code but it doesn't seem to be...
7
by: Csaba Gabor | last post by:
I need to come up with a function function regExpPos (text, re, parenNum) { ... } that will return the position within text of RegExp.$parenNum if there is a match, and -1 otherwise. For...
3
by: Peter Michaux | last post by:
Hi, In the following string I would like to find the word that comes after "test" as long as test is not inside parenthesis. In this example the match would be "two". "the (test one) test...
3
by: Russell | last post by:
hey, I'm struggling trying to get the concepts of the regExp function down.... What i'm trying to achieve is to remove all white space from html formatted source code. I have the following...
4
by: eight02645999 | last post by:
hi suppose i have a string like test1?test2t-test3*test4*test5$test6#test7*test8 how can i construct the regexp to get test3*test4*test5 and test7*test8, ie, i want to match * and the words...
4
by: Matt | last post by:
Hello all, I have just discovered (the long way) that using a RegExp object with the 'global' flag set produces inconsistent results when its test() method is executed. I realize that 'global'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.