Regular expression match issue

I have a simple regular expression: .} and some simple text: {}}

Why do I get a single match:

  • {}

I was expecting to get two:

  • {}
  • }}

Please see here for the code snippit.

--------------Solutions-------------

Regex matches are non-overlapping. Maybe some like this is closer to what you want:

/(?=})}/g

I think you actually want look behind not look ahead but this isn't supported on regexr.com because it's not supported in java script

/(?<=})}/g

Category:regex Time:2018-11-19 Views:0
Tags: regex

Related post

  • How do I avoid the implicit "^" and "$" in Java regular expression matching? 2009-03-02

    I've been struggling with doing some relatively straightforward regular expression matching in Java 1.4.2. I'm much more comfortable with the Perl way of doing things. Here's what's going on: I am attempting to match /^<foo>/ from "<foo>

  • Regular expression: match start or whitespace 2009-02-08

    Can a regular expression match whitespace or the start of a string? I'm trying to replace currency the abbreviation GBP with a £ symbol. I could just match anything starting GBP, but I'd like to be a bit more conservative, and look for certain delimi

  • What regular expression matches this pattern: 22-NOV-09 2009-12-06

    I have tried: /^([0-3][0-9])-(A-Za-z)-([0-1][0-9])?$/ and am not having success. What am I doing wrong? Thank you folks! --------------Solutions------------- /^([0-3][0-9])-([A-Z]{3})-([0-1][0-9])$/ EDIT : /^(0[1-9]|[1-2][0-9]|3[0-1])-([A-Z]{3})-(0[1

  • Regular Expression matching floating point numbers not ending with 2010-07-28

    I'm trying to extract CSS positions from a string - example: "top left bottom right center 0 0% 50% 100% 360deg 15.5% -16.3%" The problem is that the string also contains an angle "360deg". I don't want any numbers followed by "deg" to be matched by

  • java regular expression matching 2010-08-17

    What is the regular expression that can match the following 2 strings. Hi<Dog>Hi and <Dog> in a given text. Update: What regex will match this one? <FONT FACE="Verdana" SIZE="16" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">If you

  • about python regular expression match from right direction 2010-10-17

    normally,we use regular expression match from left to right direction,i want to know is there some switch can match from the right to left in python? or in any other language has this feature embedded e.g. abcd1_abcd2 if give a abcd regular expressio

  • regular expression match php 2010-10-19

    I need to do a regular expression match in php . the case is that . 2 digits before decimal and 2 digits after decimal. the problem is that it may and may not have decimal and after decimal digits . how do i write a expression for this ? ------------

  • Regular expressions: Matching filenames starting with dot (.)? 2011-01-09

    I am a complete Reg-exp noob, so please bear with me. Tried to google this, but haven't found it yet. What would be an appropriate way of writing a Regular expression matching files starting with a dot, such as .buildpath or .htaccess? Thanks a lot!

  • Regular expression - match character, digits and special characters 2011-02-08

    I have the following string: test123 test ödo 123teö"st 123 m.1212 123t.est I only want to match strings as a whole that have either characters, digits and special character mixed together. So the regex should match the following string of the exampl

  • How do I figure out which regular expression matches my string? 2011-03-09

    I have 10 regular expressions and 1 one string which may or may not match exactly one of those 10 regular expressions. Does anyone know of a simple way to figure out which regular expression, if any, matches my string? I know that I can simply test e

  • F# Mapping Regular Expression Matches with Active Patterns 2011-04-16

    I found this useful article on using Active Patterns with Regular Expressions: http://www.markhneedham.com/blog/2009/05/10/f-regular-expressionsactive-patterns/ The original code snippet used in the article was this: open System.Text.RegularExpressio

  • Can the order of regular expression matching be guaranteed in .NET? 2011-08-02

    Can the order of regular expression matching be guaranteed in .NET? If I have a string: +Apple+ +Orange+ +Banana+ +Foo+ +Bar+ +Second Line+ +More Stuff+ +Etc...+ Given the pattern (with global dot-all): \+(.*?)\+ Does the RegEx class in .NET guarante

  • 2-step regular expression matching with a variable in Perl 2011-11-01

    I am looking to do a 2-step regular expression look-up in Perl, I have text that looks like this: here is some text 9337 more text AA 2214 and some 1190 more BB stuff 8790 words I also have a hash with the following values: %my_hash = ( 9337 => 'A

  • Regular Expressions matching in Java 2012-02-03

    I am trying to generate a regular expression match in Java, that accepts all numbers that contain 3 and 7 (in any order, ie there should be at least one 7 for all 3's and vice versa) over the set of integers. So far, I have written the code below, ho

  • Expect - How can I perform multiple regular expression matches in one interact loop? 2012-02-08

    I'm trying to perform multiple regular expression matches on the same screen output, during one interact session. With the following code I'm getting the error message: "cannot use -o more than once" Ultimately I want to extract several small data va

  • multipoint regular expressions match with less for loops and less class re-initialization. optimization 2012-03-12

    Is there a way to do multiple regular expressions matches in vba without instantiating multiple instances of the regexp object? For example I want to do several points of regular expression matching between several different fields of data. For illus

  • regular expression matching producing unexpected result 2012-03-18

    here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int matchhere(char *regexp,char *text); int matchstar(int c,char *regexp,char *text); int match(char *regexp,c

  • How to implement regular expression assertions/lookaround (i.e. \b style word boundary) using a DFA regular expression matcher 2012-04-08

    I would like to implement "word boundary" matches within a DFA based regular expression matcher. Can someone tell me how this is done? To give some background, I'm currently using the "dk.brics.automaton" library, but it does not support assertions (

  • PHP regular expression match a paired tag but not unpaired tag 2012-04-21

    I am extracting a nested content of a tag. I have written a regular expression that works perfectly on my local machine (WAMP) PHP Version 5.3.8, Multibyte regex (oniguruma) version - 4.7.1 $tagname = 'mytag'; $pattern = "@<$tagname(?:\s.*?!/)?

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.713 (s). 13 q(s)