473,246 Members | 1,379 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,246 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 7039
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.