How to remove replace all characters except specified ones using regex? [closed] - regex

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I would like to remove parentheses from a string using a Regex. I see a lot of examples removing numbers or letters but those are not my case.
Thank you all

Try:
s/[()]//g
This is additional text to pass length requirements.

Try
sed 's/[()]//g' file
The regular expression [()] matches a single character which can be a left or right round parenthesis. The sed substitution operator s accepts a flag /g which says to repeat the substitution for every occurrence on each input line.

Related

Looking for a Perl Regular Expression that matches the following pattern [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
aa_bb_cc_dd_... (characters with underscores, one or more )
(or)
a1_11_1c_1... (alphanumeric characters with underscores, one or more)
(or)
aaa... (just characters, one or more)
You can try this:
^(?=.*[a-zA-Z])[A-Za-z_0-9]+$
Demo
Edited
If you want to exclude the words which contains only numbers and underscores _ , then try this.
(?![_\d]+\b)\w+
Demo
(?![_\d]+\b) : means to exclude words which is composed of numbers and underscores only.

I need regular expression that will receive exactly 9 digits starting with 5 [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have tried many alternatives but I am not reaching anywhere
/^[5]\d{9}$
can someone help.
Your regex must be like below,
^5\d{8}$
You mean this?
/5[0-9]{8}/
First a five, and then 8 times a digit.
If you want it to match anywhere, use this
/5\d{8}/
If you want it to be on a line by itself, use this instead
/^5\d{8}$/
The caret (^) means it must occur at the start of a line, and the dollar ($) means it must occur at the end of a line.

Regex to extract 1 letter followed by 7 numbers [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am struggling with using RegEx to extract the following single letter followed by seven numbers E3285270 from this URL:
http://photos.v3.torontomls.net/Live/photos/FULL/1/270/E3285270.jpg?20150812131646
Could someone please show me what regex string will grab it? Thanks.
You may use word boundaries. \b called word boundaries which matches between a word character and a non-word character.
\b[a-zA-Z]\d{7}\b
In js,
str.match(/\b\[a-z]\d{7}\b/i)[0]
DEMO

i am trying to make regex for this type of string " (hello(world)) " [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
i am trying to make regex for this type of string (hello(world))
i made this regular expression \([a-zA-Z]\([a-zA-Z])*\)\) but it gives error.... what should i have to do to make it work properly....
In regular expressions, brackets are a special character. If you want to match them literally, you need to escape them with a backslash: \(. Edit: looks like you escaped most of them, but it wasn't code formatted in your question. Fixed that, and there was only one missing escaped ).
You also are missing a quantifier (in this case another * or a + would work) that would enable it match your string, and the one you've got there is in the wrong position. This should work for you:
\([a-zA-Z]*\([a-zA-Z]*\)\)
Here's a regex101 to play around with: https://regex101.com/r/kQ0xT0/1
You can also use the /i case-insensitive modifier with most regex languages - this lets you just write [a-z] instead of [a-zA-Z]. See https://regex101.com/r/pT9kV1/1

Regex to match just the spaces only with in doublequotes [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
How to match only the spaces(not the strings) that is within double quotes and rest of the spaces must be ignored , the following regex \s(?=\") will select the only the space which is before a double quote so i was thinking there would be some sort of regex to match the space only with in double quotes
The below regex would matches the spaces which are present inside the double quotes,
\s(?!(?:[^"]*"[^"]*")*[^"]*$)
DEMO