square « Regular Expression « Javascript Data Type Q&A

Home
Javascript Data Type Q&A
1.Array
2.Clojure
3.date
4.decimal
5.function
6.global
7.loop
8.math
9.number
10.object
11.Regular Expression
12.scope
13.String
14.Var
15.variable
Javascript Data Type Q&A » Regular Expression » square 

1. Javascript - return string between square brackets    stackoverflow.com

I need to return just the text contained within square brackets in a string. I have the following regex, but this also returns the square brackets:

var matched = mystring.match("\\[.*]");
A string will ...

2. Why doesn't this JavaScript function remove square brackets one by one?    stackoverflow.com

var asdf = "a[3] > b[5] > c[1]"

function removebracket(){
var newstring = asdf.replace(/\/[^\/]*$/, '')
alert(newstring);
}

<a href="#" onClick="javascript:removebracket();"> remove square brackets one by one </a>

3. javascript regular expression followed by open square bracket    stackoverflow.com

text = text.replace(/\.(?=[a-zA-Z0-9\[])/g, "<span style='background-color: #FF00FF'>.</span>");
I want to use javascript to highlight all full stops that is followed by letters, numbers and [. The above expression works for letters and numbers, ...

4. Javascript search and replace sequence of characters that contain square brackets    stackoverflow.com

I'm trying to search for '[EN]' in the string 'Nationality [EN] [ESP]', I want to remove this from the string so I'm using a replace method, code examaple below

var str = ...

5. How to remove square brackets in string using regex?    stackoverflow.com

['abc','xyz'] – this string I want turn into abc,xyz using regex in javascript. I want to replace both open close square bracket & single quote with empty string ie "".

6. Javascript Regular Expression and square brackets    stackoverflow.com

I have a string that I need to get a number from. this is my string:

alphanumeric|minlength[2]|maxlength[7]
I need to get the minlength number. (I don't always know what the minlength number will be) How ...

7. How to remove brackets from end of string with regex    stackoverflow.com

Looking to have a recursive function that takes a string and removes the ending '[x]'. For example 'abc [1] [3]' needs to be 'abc [1]'. The string could also be ...

8. Replace text inside of square brackets    stackoverflow.com

var a = "[i] earned [c] coin for [b] bonus";
How to get string "__ earned __ coin for __ bonus" from the variable above in JavaScript? All I want to do is ...

9. Replace all commas and square brackets using Regex Expression    stackoverflow.com

Hope u people will be fine. I want to print a array variable in javascript, but the problem is that when i print the array a comma seperated list is shown. ...

10. How can I put [] (square brackets) in RegExp javascript?    stackoverflow.com

I'm trying this:

str = "bla [bla]";
str = str.replace(/\\[\\]/g,"");
console.log(str);
And the replace doesn't work, what am I doing wrong? UPDATE: I'm trying to remove any square brackets in the string, what's weird is that if ...

11. Regex to grab strings between square brackets    stackoverflow.com

I have the following string: pass[1][2011-08-21][total_passes] How would I extract the items between the square brackets into an array? I tried match(/\[(.*?)\]/); but this only returns [1]. Not sure how to do this.. Thanks ...

12. Grabbing the third fragment between square brackets    stackoverflow.com

Still completely stuck with regex's and square brackets. Hopefully someone can help me out. Say I have a string like this: room_request[1][1][2011-08-21] How would I grab the third fragment out of it? I tried the ...

13. Javascript RegEx , Find Text in Between Square Brackets    stackoverflow.com

Find:

ellora[sidebar-1]
and replace only the number, specially finding text in between square brackets (both opening and closing) and replace. Using replace()
method.result
should be like this
ellora[sidebar-2], ellora[sidebar-3], ...

14. Javascript RegExp find and replace empty square brackets    stackoverflow.com

I have a string that contains something like name="text_field_1[]" and I need to find and replace the '1[]' part so that I can increment like this '2[]', '3[]' etc Here is the ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.