Group « 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 » Group 

1. Grouping Regular expression BackReferences    stackoverflow.com

I have the following RegEx

id=(.*?) | id="(.*?)"
The reason for this is I am trying to replace Ids from the browsers DOM using JavaScript. IE, however strips quotes from element atributes as ...

2. How do you access the matched groups in a javascript regex?    stackoverflow.com

I think I must just be really tired, because this should be really simple, but it's just not working for me. I want to match a portion of a string using ...

3. Javascript replace with reference to matched group?    stackoverflow.com

I have a string, such as hello _there_. I'd like to replace the two underscores with <div> and </div> respectively, using javascript. The output would (therefore) look like hello <div>there</div>. The ...

4. How to find index of groups in match    stackoverflow.com

When i write a regular expression like:

m = /(s+).*?(l)[^l]*?(o+)/.exec( "this is hello to you" )
console.log( m );
I get a match object containing the following:
{
    0: "s is hello",
 ...

5. Javascript Regex multiple group matches in pattern    stackoverflow.com

I have a question for a Javascript regex ninja: How could I simplify my variable creation from a string using regex grouping? I currently have it working without using any grouping, ...

6. How do I fix "invalid group" error when attempting to use Gruber's "improved" URL matching regexp pattern in JavaScript?    stackoverflow.com

I'm attempting to integrate John Gruber's An Improved Liberal, Accurate Regex Pattern for Matching URLs into one of my Javascripts, but WebKit's inspector (in Google Chrome 5.0.375.125 for Mac) ...

7. javascript regexp can't find way to access grouped results    stackoverflow.com

re = /\/?(\w+)\/(\w+)/
s = '/projects/new'
s.match(re)
I have this regular expression which I will use to sieve out the branch name, e.g., projects, and the 'tip' name, e.g., new I read that one can ...

8. Javascript regex grouping question    stackoverflow.com

I want to be able to detect/pick apart strings like :

tickets at entrance per person
ballons pp
tree planting
i.e. a description followed by an optional "pp" or ...

9. JS Regex, how to replace the captured groups only?    stackoverflow.com

Ok the question is quite simple. I'm looking for a string like this one :

name="some_text_0_some_text"
I have HTML code before and after the string above. Now i would like to replace the 0 by ...

10. JavaScript regular expression exception (Invalid group)    stackoverflow.com

I have the following regular expression:

/(?<={index:)\d+(?=})/g
I am trying to find index integer in strings like this one:
some text{index:1}{id:2}{value:3}
That expression works fine with php, but it doesn't work in javascript, I get ...

11. RegExp in Javascript to group items in categories    stackoverflow.com

I need to implement a RegExp in Javascript that allows me to match the following categories and items, associating the items to their proper category, but I don't know how:

<table>
  ...

12. Regex: Do not include a substring within a group    stackoverflow.com

I'm wondering if it is possible to exclude part of a match within a group. I believe that /(foo((?:bar)|(bad)))/ results in matching "foobar" or "foobad" and group 1 containing "foobar" or "foobad". ...

13. how to split into character group?    stackoverflow.com

I want to split string

"abcdefgh"
to
"ab","cd","ef","gh"
using javascript split()
"abcdefgh".split(???)
Can you please help ?

14. Referencing nested groups in JavaScript using string replace using regex    stackoverflow.com

Because of the way that jQuery deals with script tags, I've found it necessary to do some HTML manipulation using regular expressions (yes, I know... not the ideal tool for the ...

15. group parts of a string into an array element    stackoverflow.com

If I have a string... abcdefghi and I want to use regex to load every elemnent into an array but I want to be able to stick anything connected by plus sign ...

16. Is there a group of groups in Regex in javascript or any other language    stackoverflow.com

I was just playing with the native replace method for strings in javascript. Is there any thing like groups of groups. If not, how are groups ordered in string where a ...

17. How to get the Indices of a Matching Group in a Regular Expression in JavaScript    stackoverflow.com

Given the JavaScript following code

var patter = /abc(d)e/
var somestring = 'abcde'
var index = somestring.match(patter)
I would like to know the start index of a group match, just like in java

18. How to get matched group when passing a function to replace?    stackoverflow.com

I have following code:

this.parse = function(whatToParse, currentItem) {
    var re = /\{j\s([a-z0-9\.\|_]+)\ss\}/gi;
    var newResult = whatToParse.replace(re, function(matches){
        alert(matches);
 ...

19. Javascript Regex to split a string into array of grouped/contiguous characters    stackoverflow.com

I'm trying to do the same thing that this guy is doing, only he's doing it in Ruby and I'm trying to do it via Javascript: Split a string into an ...

20. Prevent regex group from including previous character?    stackoverflow.com

I'm attempting to get any words starting with @, such as in "@word", but only get the "word" value. My sample text is:

@bob asodija qwwiq qwe @john @cat asdasd@qeqwe 
My current regex ...

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.