Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

/
/
gmis

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?mis)<script*[^>]*>(.+?)<\/script[^>]*>|<!--*(.+?)-->|<style*[^>]*>(.+?)<\/style[^>]*>|<javascript*[^>]*>(.*?)<\/javascript[^>]*>|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>" Local $sString = "<!DOCTYPE html>" & @CRLF & _ "<html itemscope itemtype="http://schema.org/QAPage">" & @CRLF & _ "<head>" & @CRLF & _ "" & @CRLF & _ "<title>java - Regex to match single quotes being quoted by double-quotes - Stack Overflow</title>" & @CRLF & _ " <link rel="shortcut icon" href="//cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d">" & @CRLF & _ " <link rel="apple-touch-icon image_src" href="//cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">" & @CRLF & _ " <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">" & @CRLF & _ " <meta name="twitter:card" content="summary">" & @CRLF & _ " <meta name="twitter:domain" content="stackoverflow.com"/>" & @CRLF & _ " <meta property="og:type" content="website" /> " & @CRLF & _ " <meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded&a" />" & @CRLF & _ " <meta name="twitter:title" property="og:title" itemprop="title name" content="Regex to match single quotes being quoted by double-quotes" />" & @CRLF & _ " <meta name="twitter:description" property="og:description" itemprop="description" content="Here is a Regex I have been trying to make work:" & @CRLF & _ "" & @CRLF & _ "(?:&quot;[^&quot;]*&quot;[^&quot;]*)*?\&quot;{1}([^&quot;]*?([&#39;]{1,})[^&quot;]*?)\&quot;" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "It is probably not the most clean nor the most effective way to achieve what I want to do, but I&#39;m " />" & @CRLF & _ " <meta property="og:url" content="http://stackoverflow.com/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes"/>" & @CRLF & _ " <link rel="canonical" href="http://stackoverflow.com/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes" />" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " <javascript src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" />abc" & @CRLF & _ "<javascript src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></javascript>" & @CRLF & _ " <javascript src="//cdn.sstatic.net/Js/stub.en.js?v=c1341d3ea930"></javascript> " & @CRLF & _ " <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" />abc" & @CRLF & _ "<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>" & @CRLF & _ " <script src="//cdn.sstatic.net/Js/stub.en.js?v=c1341d3ea930"></script>" & @CRLF & _ " <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/stackoverflow/all.css?v=3f4c51969762">" & @CRLF & _ "text goes here" & @CRLF & _ " <link rel="alternate" type="application/atom+xml" title="Feed for question &#39;Regex to match single quotes being quoted by double-quotes&#39;" href="/feeds/question/36183788">" & @CRLF & _ " <meta name="twitter:app:country" content="US" />" & @CRLF & _ " <meta name="twitter:app:name:iphone" content="Stack Exchange iOS" />" & @CRLF & _ " <meta name="twitter:app:id:iphone" content="871299723" />" & @CRLF & _ " <meta name="twitter:app:url:iphone" content="se-zaphod://stackoverflow.com/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes" />" & @CRLF & _ " <meta name="twitter:app:name:ipad" content="Stack Exchange iOS" />" & @CRLF & _ " <meta name="twitter:app:id:ipad" content="871299723" />" & @CRLF & _ " <meta name="twitter:app:url:ipad" content="se-zaphod://stackoverflow.com/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes" />" & @CRLF & _ " <meta name="twitter:app:name:googleplay" content="Stack Exchange Android">" & @CRLF & _ " <meta name="twitter:app:url:googleplay" content="http://stackoverflow.com/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes">" & @CRLF & _ " <meta name="twitter:app:id:googleplay" content="com.stackexchange.marvin">" & @CRLF & _ " <script>" & @CRLF & _ " " & @CRLF & _ " StackExchange.ready(function () {" & @CRLF & _ " " & @CRLF & _ " StackExchange.using("snippets", function () {" & @CRLF & _ " StackExchange.snippets.initSnippetRenderer();" & @CRLF & _ " });" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " StackExchange.using("postValidation", function () {" & @CRLF & _ " StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');" & @CRLF & _ " });" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " StackExchange.question.init({showAnswerHelp:true,totalCommentCount:5,shownCommentCount:5,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId:36183788});" & @CRLF & _ "" & @CRLF & _ " styleCode();" & @CRLF & _ "" & @CRLF & _ " StackExchange.realtime.subscribeToQuestion('1', '36183788');" & @CRLF & _ " StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks('#content', '.post-text'); });" & @CRLF & _ "" & @CRLF & _ " });" & @CRLF & _ " </script>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <script>" & @CRLF & _ " StackExchange.init({"locale":"en","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","serverTime":1462811219,"routeName":"Questions/Show","styleCode":true,"enableUserHovercards":true,"snippets":{"enabled":true,"domain":"stacksnippets.net"},"site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","recaptchaAudioLang":"en","enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"enableSocialMediaInSharePopup":true},"user":{"fkey":"854f77cbe5f2c1ef88213c404c702005","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true}});" & @CRLF & _ " StackExchange.using.setCacheBreakers({"js/prettify-full.en.js":"d27a06f9e057","js/moderator.en.js":"c7f3a2fe6f43","js/full-anon.en.js":"fcc366214c65","js/full.en.js":"22860c74fefe","js/wmd.en.js":"4b1b73828836","js/third-party/jquery.autocomplete.min.js":"e5f01e97f7c3","js/third-party/jquery.autocomplete.min.en.js":"","js/mobile.en.js":"3199d1e28733","js/help.en.js":"c8004cc0095d","js/tageditor.en.js":"bd4fb7a0a976","js/tageditornew.en.js":"93c9f772766c","js/inline-tag-editing.en.js":"4fa1a4a3339e","js/revisions.en.js":"47de10a8358f","js/review.en.js":"52b85f4f645b","js/tagsuggestions.en.js":"d1ff9b84abe5","js/post-validation.en.js":"769557d5981d","js/explore-qlist.en.js":"e71f14781288","js/events.en.js":"e27da81910e7","js/keyboard-shortcuts.en.js":"625602e443f6","js/external-editor.en.js":"d55cf33307e5","js/external-editor.en.js":"d55cf33307e5","js/snippet-javascript.en.js":"857907519d98","js/snippet-javascript-codemirror.en.js":"17f3b3b6b34d"});" & @CRLF & _ " StackExchange.using("gps", function() {" & @CRLF & _ " StackExchange.gps.init(true);" & @CRLF & _ " });" & @CRLF & _ " </script>" & @CRLF & _ " " & @CRLF & _ " <script>" & @CRLF & _ " StackExchange.ready(function () {" & @CRLF & _ " $('#nav-tour').click(function () {" & @CRLF & _ " StackExchange.using("gps", function() {" & @CRLF & _ " StackExchange.gps.track("aboutpage.click", { aboutclick_location: "headermain" }, true);" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ " </script>" & @CRLF & _ "</head>" & @CRLF & _ "<body class="question-page new-topbar">" & @CRLF & _ " <noscript><div id="noscript-padding"></div></noscript>" & @CRLF & _ " " & @CRLF & _ " <script>(function () { var old = $.fn.contents; $.fn.contents = function () { try { return old.apply(this, arguments); } catch (e) { return $([]); } } })()</script>" & @CRLF & _ " <iframe id="adzerk-user-match" width="0" height="0" frameborder="0" scrolling="no" onload="window.AUMIframeDone=true"" & @CRLF & _ " src="https://ssum-sec.casalemedia.com/usermatch?s=183712&amp;cb=https%3A%2F%2Fengine.adzerk.net%2Fudb%2F22%2Fsync%2Fi.gif%3FpartnerId%3D1%26userId%3D"" & @CRLF & _ " style="display: none;" marginheight="0" marginwidth="0"></iframe>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <div id="notify-container"></div>" & @CRLF & _ " <div id="overlay-header"></div>" & @CRLF & _ " <div id="custom-header"></div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "For example, /a+/ matches the 'a' in "candy" <script stuff here />more stuff</script>and all the a's in "caaaaaaandy", but nothing in "cndy". Matches the preceding expression 0 or 1 time. Equivalent to {0,1}.<script />" & @CRLF & _ "<script>this is stuff</script><script src="'abc'http://wwwtest.com">code would go here </font>" & @CRLF & _ " </script>For example, /e?le?/ matches the 'el' in "angel" and the 'le' in "angle" and also the 'l' in "oslo". For example, /Jack(?=Sprat)/ matches 'Jack' only if it is followed by 'Sprat'. /Jack(?=Sprat|Frost)/ matches 'Jack' only if it is followed by 'Sprat' or 'Frost'. JackSprat Jack Sprat However, <script></script>neither 'Sprat' nor 'Frost' is part of the match results." & @CRLF & _ "" & @CRLF & _ "Here are a few examples:" & @CRLF & _ "" This is a random sentence ' with a quote, the quote should match"" & @CRLF & _ "" There is no quote here thats the problem" Anything here should not match but now it does: ' ." & @CRLF & _ "Some text " some more text " this is a quote : ' that should match" & @CRLF & _ "" When there is a quote (') here, the other one does not work : " ' and that's perfect " even if you remove the first one this : " (') " will make it work because of the greedy ( I think ) but ifyou remove those between parenthesis, the other one is matching as of now, which I do not want to happen." & @CRLF & _ "Another example would be this one : The following should not work, but it does "This is being quoted" not this: (') " and this is also being quoted "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "<div class="topbar">" & @CRLF & _ " <div class="topbar-wrapper">" & @CRLF & _ "" & @CRLF & _ " <div class="js-topbar-dialog-corral">" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "<div class="topbar-dialog siteSwitcher-dialog dno">" & @CRLF & _ " <div class="header">" & @CRLF & _ " <h3><a href="//stackoverflow.com">current community</a></h3>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="modal-content current-site-container">" & @CRLF & _ " <ul class="current-site">" & @CRLF & _ " <li>" & @CRLF & _ " <div class="related-links">" & @CRLF & _ " <a href="http://chat.stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })"" & @CRLF & _ ">chat</a>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <a href="//stackoverflow.com"" & @CRLF & _ " class="current-site-link site-link js-gps-track"" & @CRLF & _ " data-id="1"" & @CRLF & _ " data-gps-track="" & @CRLF & _ " site_switcher.click({ item_type:3 })">" & @CRLF & _ " <div class="site-icon favicon favicon-stackoverflow" title="Stack Overflow"></div>" & @CRLF & _ " Stack Overflow" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="related-site">" & @CRLF & _ " <div class="L-shaped-icon-container">" & @CRLF & _ " <span class="L-shaped-icon"></span>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <a href="http://meta.stackoverflow.com"" & @CRLF & _ " class="site-link js-gps-track"" & @CRLF & _ " data-id="552"" & @CRLF & _ " data-gps-track="" & @CRLF & _ " site.switch({ target_site:552, item_type:3 })," & @CRLF & _ " site_switcher.click({ item_type:4 })">" & @CRLF & _ " <div class="site-icon favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div>" & @CRLF & _ " Meta Stack Overflow" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="related-site">" & @CRLF & _ " <div class="L-shaped-icon-container">" & @CRLF & _ " <span class="L-shaped-icon"></span>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <a class="site-link js-gps-track"" & @CRLF & _ " href="//careers.stackoverflow.com?utm_source=stackoverflow.com&amp;utm_medium=site-ui&amp;utm_campaign=multicollider"" & @CRLF & _ " data-gps-track="site_switcher.click({ item_type:9 })"" & @CRLF & _ ">" & @CRLF & _ " <div class="site-icon favicon favicon-careers" title="Stack Overflow Careers"></div>" & @CRLF & _ " Stack Overflow Careers" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " </ul>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="header" id="your-communities-header">" & @CRLF & _ " <h3>" & @CRLF & _ "your communities </h3>" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <div class="modal-content" id="your-communities-section">" & @CRLF & _ " " & @CRLF & _ " <div class="call-to-login">" & @CRLF & _ "<a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&amp;returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f36183788%2fregex-to-match-single-quotes-being-quoted-by-double-quotes" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })"" & @CRLF & _ ">Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&amp;returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f36183788%2fregex-to-match-single-quotes-being-quoted-by-double-quotes" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })"" & @CRLF & _ ">log in</a> to customize your list." & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="header">" & @CRLF & _ " <h3><a href="//stackexchange.com/sites">more stack exchange communities</a></h3>" & @CRLF & _ " <a href="http://blog.stackoverflow.com" class="fr">company blog</a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="modal-content">" & @CRLF & _ " <div class="child-content"></div>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div class="network-items">" & @CRLF & _ "" & @CRLF & _ " <a href="//stackexchange.com"" & @CRLF & _ " class="topbar-icon icon-site-switcher yes-hover js-site-switcher-button js-gps-track"" & @CRLF & _ " data-gps-track="site_switcher.show"" & @CRLF & _ " title="A list of all 155 Stack Exchange sites">" & @CRLF & _ " <span class="hidden-text">Stack Exchange</span>" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " <a href="#"" & @CRLF & _ " class="topbar-icon icon-inbox yes-hover js-inbox-button"" & @CRLF & _ " title="Recent inbox messages">" & @CRLF & _ " <span class="hidden-text">Inbox</span>" & @CRLF & _ " <span class="unread-count" style="display:none"></span>" & @CRLF & _ " </a>" & @CRLF & _ " <a href="#"" & @CRLF & _ " class="topbar-icon icon-achievements yes-hover js-achievements-button "" & @CRLF & _ " data-unread-class=""" & @CRLF & _ " title="Recent achievements: reputation, badges, and privileges earned">" & @CRLF & _ " <span class="hidden-text">Reputation and Badges</span>" & @CRLF & _ " <span class="unread-count" style="display:none">" & @CRLF & _ " " & @CRLF & _ " </span>" & @CRLF & _ " </a>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div class="topbar-links">" & @CRLF & _ "" & @CRLF & _ " <div class="links-container">" & @CRLF & _ " <span class="topbar-menu-links">" & @CRLF & _ " <a href="https://stackoverflow.com/users/signup?ssrc=head&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f36183788%2fregex-to-match-single-quotes-being-quoted-by-double-quotes" class="login-link">sign up</a>" & @CRLF & _ " <a href="https://stackoverflow.com/users/login?ssrc=head&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f36183788%2fregex-to-match-single-quotes-being-quoted-by-double-quotes" class="login-link">log in</a>" & @CRLF & _ "" & @CRLF & _ " <a href="/tour">tour</a>" & @CRLF & _ " <a href="#" class="icon-help js-help-button" title="Help Center and other resources">" & @CRLF & _ " help" & @CRLF & _ " <span class="triangle"></span>" & @CRLF & _ " </a>" & @CRLF & _ " <div class="topbar-dialog help-dialog js-help-dialog dno">" & @CRLF & _ " <div class="modal-content">" & @CRLF & _ " <ul>" & @CRLF & _ " <li>" & @CRLF & _ " <a href="/tour" class="js-gps-track" data-gps-track="help_popup.click({ item_type:1 })">" & @CRLF & _ " Tour" & @CRLF & _ " <span class="item-summary">" & @CRLF & _ " Start here for a quick overview of the site" & @CRLF & _ " </span>" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " <li>" & @CRLF & _ " <a href="/help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:4 })">" & @CRLF & _ " Help Center" & @CRLF & _ " <span class="item-summary">" & @CRLF & _ " Detailed answers to any questions you might have" & @CRLF & _ " </span>" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " <li>" & @CRLF & _ " <a href="//meta.stackoverflow.com" class="js-gps-track" data-gps-track="help_popup.click({ item_type:2 })">" & @CRLF & _ " Meta" & @CRLF & _ " <span class="item-summary">" & @CRLF & _ " Discuss the workings and policies of this site" & @CRLF & _ " </span>" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " <li>" & @CRLF & _ " <a href="http://stackoverflow.com/company/about" class="js-gps-track" data-gps-track="help_popup.click({ item_type:6 })">" & @CRLF & _ " About Us" & @CRLF & _ " <span class="item-summary">" & @CRLF & _ " Learn more about Stack Overflow the company" & @CRLF & _ " </span>" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " <li>" & @CRLF & _ " <a href="https://business.stackoverflow.com/?ref=topbar_help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:7 })">" & @CRLF & _ " Business" & @CRLF & _ " <span class="item-summary">" & @CRLF & _ " Learn more about hiring developers or posting ads with us" & @CRLF & _ " </span>" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " </ul>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " </span>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div class="search-container">" & @CRLF & _ " <form id="search" action="/search" method="get" autocomplete="off">" & @CRLF & _ " <input name="q" type="text" placeholder="Search Q&amp;A" value="" tabindex="1" autocomplete="off" maxlength="240" />" & @CRLF & _ " </form>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ " <script>" & @CRLF & _ " StackExchange.ready(function() { StackExchange.topbar.init(); });" & @CRLF & _ " </script>" & @CRLF & _ "" & @CRLF & _ " <div class="container">" & @CRLF & _ " <div id="header">" & @CRLF & _ " <br class="cbt">" & @CRLF & _ " <div id="hlogo">" & @CRLF & _ " <a href="/" >" & @CRLF & _ " Stack Overflow" & @CRLF & _ " </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div id="hmenus">" & @CRLF & _ " <div class="nav mainnavs">" & @CRLF & _ " <ul>" & @CRLF & _ " <li class="youarehere"><a id="nav-questions" href="/questions">Questions</a></li>" & @CRLF & _ " <li><a id="nav-jobs" href="/jobs">Jobs</a></li>" & @CRLF & _ " <li><a id="nav-tags" href="/tags">Tags</a></li>" & @CRLF & _ " <li><a id="nav-users" href="/users">Users</a></li>" & @CRLF & _ " <li><a id="nav-badges" href="/help/badges">Badges</a></li>" & @CRLF & _ " </ul>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="nav askquestion">" & @CRLF & _ " <ul>" & @CRLF & _ " <li>" & @CRLF & _ " <a id="nav-askquestion" href="/questions/ask">Ask Question</a>" & @CRLF & _ " </li>" & @CRLF & _ " </ul>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <div id="content" class="snippet-hidden">" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<div itemscope itemtype="http://schema.org/Question">" & @CRLF & _ " <link itemprop="image" href="//cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">" & @CRLF & _ "" & @CRLF & _ "<div id="herobox">" & @CRLF & _ " <div id="hero-content">" & @CRLF & _ " <div id="close"><a title="click to minimize">_</a></div>" & @CRLF & _ " <div id="blurb">" & @CRLF & _ " Stack Overflow is a community of 4.7 million programmers, just like you, helping each other." & @CRLF & _ " <br/>" & @CRLF & _ " <br/>Join them; it only takes a minute:<br/>" & @CRLF & _ " <br/>" & @CRLF & _ " <a href="/users/signup?ssrc=hero&amp;returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f36183788%2fregex-to-match-single-quotes-being-quoted-by-double-quotes" id="tell-me-more" class="button">Sign up</a>" & @CRLF & _ " </div>" & @CRLF & _ " <div id="desc">" & @CRLF & _ " <b>Join the Stack Overflow community to:</b>" & @CRLF & _ " <ol id="hiw">" & @CRLF & _ " <li id="q">Ask programming questions" & @CRLF & _ " </li>" & @CRLF & _ " <li id="an">Answer and help your peers" & @CRLF & _ " </li>" & @CRLF & _ " <li id="b">Get recognized for your expertise" & @CRLF & _ " </li>" & @CRLF & _ " </ol>" & @CRLF & _ " </div>" & @CRLF & _ " <div style="clear: both"></div>" & @CRLF & _ " </div>" & @CRLF & _ " <script>" & @CRLF & _ " StackExchange.ready(function () {" & @CRLF & _ "" & @CRLF & _ " var location = 0;" & @CRLF & _ " if ($("body").hasClass("questions-page")) {" & @CRLF & _ " location = 1;;" & @CRLF & _ " } else if ($("body").hasClass("question-page")) {" & @CRLF & _ " location = 1;;" & @CRLF & _ " } else if ($("body").hasClass("faq-page")) {" & @CRLF & _ " location = 5;;" & @CRLF & _ " } else if ($("body").hasClass("home-page")) {" & @CRLF & _ " location = 3;;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " $('#tell-me-more').click(function () {" & @CRLF & _ " StackExchange.using("gps", function () {" & @CRLF & _ " StackExchange.gps.track("hero.action", { hero_action_type: 'cta', location: location }, true);" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ " $('#herobox #close').click(function () {" & @CRLF & _ " StackExchange.using("gps", function () {" & @CRLF & _ " StackExchange.gps.track("hero.action", { hero_action_type: "minimize", location: location }, true);" & @CRLF & _ " });" & @CRLF & _ " $.cookie("hero", "mini", { path: "/", expires: 365 });" & @CRLF & _ " $.ajax({" & @CRLF & _ " url: "/hero-mini"," & @CRLF & _ " success: function (data) {" & @CRLF & _ " $("#herobox").fadeOut("fast", function () {" & @CRLF & _ " $("#herobox").replaceWith(data);" & @CRLF & _ " $("#herobox-mini").fadeIn("fast");" & @CRLF & _ " });" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ " return false;" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ "" & @CRLF & _ " </script>" & @CRLF & _ "</div>" & @CRLF & _ " <div id="question-header">" & @CRLF & _ " <h1 itemprop="name"><a href="/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes" class="question-hyperlink">Regex to match single quotes being quoted by double-quotes</a></h1>" & @CRLF & _ " </div>" & @CRLF & _ " <div id="mainbar">" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<div class="question" data-questionid="36183788" id="question">" & @CRLF & _ "" & @CRLF & _ " <script>" & @CRLF & _ " var ados = ados || {}; ados.run = ados.run || [];" & @CRLF & _ " ados.run.push(function () { ados_add_placement(22,8277,"adzerk1151348596",4).setZone(43); });" & @CRLF & _ " </script>" & @CRLF & _ " <div class="everyonelovesstackoverflow" id="adzerk1151348596">" & @CRLF & _ " </div> <table>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="votecell">" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<div class="vote">" & @CRLF & _ " <input type="hidden" name="_id_" value="36183788">" & @CRLF & _ " <a class="vote-up-off" title="This question shows research effort; it is useful and clear">up vote</a>" & @CRLF & _ " <span itemprop="upvoteCount" class="vote-count-post ">3</span>" & @CRLF & _ " <a class="vote-down-off" title="This question does not show any research effort; it is unclear or not useful">down vote</a>" & @CRLF & _ "" & @CRLF & _ " <a class="star-off" href="#">favorite</a>" & @CRLF & _ " <div class="favoritecount"><b></b></div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " </td>" & @CRLF & _ " " & @CRLF & _ "<td class="postcell">" & @CRLF & _ "<div>" & @CRLF & _ " <div class="post-text" itemprop="text">" & @CRLF & _ "" & @CRLF & _ "<p>Here is a Regex I have been trying to make work:</p>" & @CRLF & _ "" & @CRLF & _ "<pre><code>(?:"[^"]*"[^"]*)*?\"{1}([^"]*?([']{1,})[^"]*?)\"" & @CRLF & _ "</code></pre>" & @CRLF & _ "" & @CRLF & _ "<p>It is probably not the most clean nor the most effective way to achieve what I want to do, but I'm almost there, I think.</p>" & @CRLF & _ "" & @CRLF & _ "<p><strong>My goal is to match any single quote (') <em>that's being quoted</em> between double-quotes (")</strong>, so there needs to be an odd amount of double quotes in front of it. I know that for now it only matches the first group of single quotes, that's fine. I will eventually use this regex to replace the first occurence then iterate and use it again to replace the others as long as there are some.</p>" & @CRLF & _ "" & @CRLF & _ "<p>Here are a few examples:</p>" & @CRLF & _ "" & @CRLF & _ "<ul>" & @CRLF & _ "<li>" This is a random sentence <strong>'</strong> with a quote, <strong>the quote should match</strong>"</li>" & @CRLF & _ "<li>" There is no quote here thats the problem" Anything here <strong>should not match</strong> but now it does: <strong>'</strong> .</li>" & @CRLF & _ "<li>" Some text " some more text " this <strong>is a quote : ' that should match</strong>" </li>" & @CRLF & _ "<li>" When there is a quote (') here, the other one does not work : " ' and that's perfect " even if you remove the first one this : " (') " will make it work because of the greedy ( I think ) but ifyou remove those between parenthesis, the other one is matching as of now, which I do not want to happen.</li>" & @CRLF & _ "<li>Another example would be this one : The following should not work, but it does "This is being quoted" not this: (') " and this is also being quoted "</li>" & @CRLF & _ "</ul>" & @CRLF & _ "" & @CRLF & _ "<p>Note that I really do not consider myself an expert, a few days ago I knew almost nothing except the classic [a-zA-Z0-9]... Any help is welcome, I may have overlooked something basic.</p>" & @CRLF & _ "" & @CRLF & _ "<p>I have been working it here:" & @CRLF & _ "<a href="https://regex101.com/r/aE7iB8/1" rel="nofollow">https://regex101.com/r/aE7iB8/1</a></p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="post-taglist">" & @CRLF & _ " <a href="/questions/tagged/java" class="post-tag" title="show questions tagged &#39;java&#39;" rel="tag">java</a> <a href="/questions/tagged/regex" class="post-tag" title="show questions tagged &#39;regex&#39;" rel="tag">regex</a> " & @CRLF & _ " </div>" & @CRLF & _ " <table class="fw">" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="vt">" & @CRLF & _ "<div class="post-menu"><a href="/q/36183788" title="short permalink to this question" class="short-link" id="link-post-36183788">share</a><span class="lsep">|</span><a href="/posts/36183788/edit" class="suggest-edit-post" title="">improve this question</a></div> " & @CRLF & _ " </td>" & @CRLF & _ " <td align="right" class="post-signature">" & @CRLF & _ "<div class="user-info ">" & @CRLF & _ " <div class="user-action-time">" & @CRLF & _ " <a href="/posts/36183788/revisions" title="show all edits to this post">edited <span title="2016-03-23 18:39:27Z" class="relativetime">Mar 23 at 18:39</span></a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-gravatar32">" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-details">" & @CRLF & _ " " & @CRLF & _ " <div class="-flair">" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</div> </td>" & @CRLF & _ " <td class="post-signature owner">" & @CRLF & _ " <div class="user-info ">" & @CRLF & _ " <div class="user-action-time">" & @CRLF & _ " asked <span title="2016-03-23 16:35:05Z" class="relativetime">Mar 23 at 16:35</span>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-gravatar32">" & @CRLF & _ " <a href="/users/4425156/rapha%c3%abl"><div class="gravatar-wrapper-32"><img src="https://graph.facebook.com/807064487/picture?type=large" alt="" width="32" height="32"></div></a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-details">" & @CRLF & _ " <a href="/users/4425156/rapha%c3%abl">Rapha&#235;l</a>" & @CRLF & _ " <div class="-flair">" & @CRLF & _ " <span class="reputation-score" title="reputation score " dir="ltr">133</span><span title="7 bronze badges"><span class="badge3"></span><span class="badgecount">7</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ "</div>" & @CRLF & _ "</td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ "<tr>" & @CRLF & _ " <td class="votecell"></td>" & @CRLF & _ " <td>" & @CRLF & _ " <div id="comments-36183788" class="comments ">" & @CRLF & _ " <table>" & @CRLF & _ " <tbody data-remaining-comments-count="0"" & @CRLF & _ " data-canpost="false"" & @CRLF & _ " data-cansee="true"" & @CRLF & _ " data-comments-unavailable="false"" & @CRLF & _ " data-addlink-disabled="true">" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <tr id="comment-60009490" class="comment ">" & @CRLF & _ " <td>" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " &nbsp;&nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">I think you have an incorrect assumption, and that&#39;s that there needs to be an odd number of double quotes in front of it (depending on what text is allowed). What about the counter-example <code>&#39;&quot;&quot;&quot;\&#39;&quot;&#39;</code>? Instead of using regex, you should definitely be using a stack.</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/2415524/mbomb007"" & @CRLF & _ " title="1,447 reputation"" & @CRLF & _ " class="comment-user">mbomb007</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 19:30:19Z" class="relativetime-clean">Mar 23 at 19:30</span></span>" & @CRLF & _ " <span class="edited-yes" title="this comment was edited 5 times"></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr id="comment-60010023" class="comment ">" & @CRLF & _ " <td>" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " &nbsp;&nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">I am not sure I understand what you mean, wouldnt the second &#39; be matched if we check if there are an odd number of &quot; in front of it ?</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/4425156/rapha%c3%abl"" & @CRLF & _ " title="133 reputation"" & @CRLF & _ " class="comment-user owner">Rapha&#235;l</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 19:48:00Z" class="relativetime-clean">Mar 23 at 19:48</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr id="comment-60010035" class="comment ">" & @CRLF & _ " <td>" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " &nbsp;&nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">It all depends if you allow nested quotes. Either way, regex is the wrong tool for the job.</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/2415524/mbomb007"" & @CRLF & _ " title="1,447 reputation"" & @CRLF & _ " class="comment-user">mbomb007</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 19:48:33Z" class="relativetime-clean">Mar 23 at 19:48</span></span>" & @CRLF & _ " <span class="edited-yes" title="this comment was edited 2 times"></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr id="comment-60010107" class="comment ">" & @CRLF & _ " <td>" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " &nbsp;&nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">if I add another double-quote in front of it, it then wouldnt match, which is what I am aiming for: &quot;this is some quoted text&quot; this is not &quot; this is &quot;, maybe I dont understand what you&#39;re meaning</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/4425156/rapha%c3%abl"" & @CRLF & _ " title="133 reputation"" & @CRLF & _ " class="comment-user owner">Rapha&#235;l</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 19:50:51Z" class="relativetime-clean">Mar 23 at 19:50</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr id="comment-60010239" class="comment ">" & @CRLF & _ " <td>" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " &nbsp;&nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">Ah,no there wont be nested quotes</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/4425156/rapha%c3%abl"" & @CRLF & _ " title="133 reputation"" & @CRLF & _ " class="comment-user owner">Rapha&#235;l</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 19:54:55Z" class="relativetime-clean">Mar 23 at 19:54</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div id="comments-link-36183788" data-rep=50 data-anon=true>" & @CRLF & _ "" & @CRLF & _ " <a class="js-add-link comments-link disabled-link "" & @CRLF & _ " title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments."" & @CRLF & _ " >add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span>" & @CRLF & _ " <a class="js-show-link comments-link dno" title="expand to show all comments on this post" href=# onclick=""></a>" & @CRLF & _ " </div> " & @CRLF & _ " </td>" & @CRLF & _ "</tr> </table>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " <div id="answers">" & @CRLF & _ "" & @CRLF & _ " <a name="tab-top"></a>" & @CRLF & _ " <div id="answers-header">" & @CRLF & _ " <div class="subheader answers-subheader">" & @CRLF & _ " <h2>" & @CRLF & _ " 2 Answers" & @CRLF & _ " <span style="display:none;" itemprop="answerCount">2</span>" & @CRLF & _ " </h2>" & @CRLF & _ " <div>" & @CRLF & _ " <div id="tabs">" & @CRLF & _ " <a href="/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes?answertab=active#tab-top" data-nav-xhref="" title="Answers with the latest activity first" data-value="active">" & @CRLF & _ " active</a>" & @CRLF & _ " <a href="/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes?answertab=oldest#tab-top" data-nav-xhref="" title="Answers in the order they were provided" data-value="oldest">" & @CRLF & _ " oldest</a>" & @CRLF & _ " <a class="youarehere" href="/questions/36183788/regex-to-match-single-quotes-being-quoted-by-double-quotes?answertab=votes#tab-top" data-nav-xhref="" title="Answers with the highest score first" data-value="votes">" & @CRLF & _ " votes</a>" & @CRLF & _ "</div>" & @CRLF & _ " </div>" & @CRLF & _ " </div> " & @CRLF & _ " </div> " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "<a name="36186925"></a>" & @CRLF & _ "<div id="answer-36186925" class="answer accepted-answer" data-answerid="36186925" itemscope itemtype="http://schema.org/Answer" itemprop="acceptedAnswer">" & @CRLF & _ " <table>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="votecell">" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<div class="vote">" & @CRLF & _ " <input type="hidden" name="_id_" value="36186925">" & @CRLF & _ " <a class="vote-up-off" title="This answer is useful">up vote</a>" & @CRLF & _ " <span itemprop="upvoteCount" class="vote-count-post ">2</span>" & @CRLF & _ " <a class="vote-down-off" title="This answer is not useful">down vote</a>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <span class="vote-accepted-on load-accepted-answer-date" title="loading when this answer was accepted...">accepted</span>" & @CRLF & _ "" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " </td>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "<td class="answercell">" & @CRLF & _ " <div class="post-text" itemprop="text">" & @CRLF & _ "<p>Well, here is a regex that works on all your samples - but it's a bit longer and not really perfectly readable. I hope I got all the escapes correctly for the java pattern.</p>" & @CRLF & _ "" & @CRLF & _ "<pre><code>(?:(?:^|\\G(?&lt;!^)[^'\"]*\")[^\"]*+(?:"[^\"']*"[^\"]*)*+"|\\G(?&lt;!^))[^'\"]*+(')" & @CRLF & _ "</code></pre>" & @CRLF & _ "" & @CRLF & _ "<p>This makes use of the <code>\G</code>-matcher, that will match at the end of the last pattern and of possesive modifiers to avoid unnecessary backtracking.</p>" & @CRLF & _ "" & @CRLF & _ "<p>Let's start at the end, <code>[^'\"]*+(')</code> matches any character, thats not single or double quote followed by a single quote, that is captured into a group.</p>" & @CRLF & _ "" & @CRLF & _ "<p><code>\\G(?&lt;!^)</code> matches at the end of the last match (the <code>(?&lt;!^)</code> is used to ensure we are not at the start of the string, as that is the position of <code>\G</code> in the first run, before anything is matched. So we will just try, if there is another single quote inside the double quotes we were in the last match.</p>" & @CRLF & _ "" & @CRLF & _ "<p><code>(?:^|\\G(?&lt;!^)[^'\"]*\")[^\"]*+(?:"[^\"']*"[^\"]*)*+"</code> is used to jump over all sequences that are either outside double quotes or don't contain a single quote. <code>^|\\G(?&lt;!^)[^'\"]*\"</code> matches either the start of the string (first match) or matches until the closing double quote of our last match, if there is not other single quote inside. <code>[^\"]*+</code> then matches anything that's not a double quote. <code>(?:"[^\"']*"[^\"]*)*+"</code> then matches any double quotes that don't contain single quotes and sequences outside single quotes until we reach the double quote that starts our matching for the single quote.</p>" & @CRLF & _ "" & @CRLF & _ "<p>But I guess a demo shows it way better than I can explain, so here you are: <a href="https://regex101.com/r/tW5xH4/1" rel="nofollow">https://regex101.com/r/tW5xH4/1</a></p>" & @CRLF & _ " </div>" & @CRLF & _ " <table class="fw">" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="vt">" & @CRLF & _ "<div class="post-menu"><a href="/a/36186925" title="short permalink to this answer" class="short-link" id="link-post-36186925">share</a><span class="lsep">|</span><a href="/posts/36186925/edit" class="suggest-edit-post" title="">improve this answer</a></div> </td>" & @CRLF & _ " <td align="right" class="post-signature">" & @CRLF & _ "<div class="user-info ">" & @CRLF & _ " <div class="user-action-time">" & @CRLF & _ " <a href="/posts/36186925/revisions" title="show all edits to this post">edited <span title="2016-03-23 19:26:36Z" class="relativetime">Mar 23 at 19:26</span></a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-gravatar32">" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-details">" & @CRLF & _ " " & @CRLF & _ " <div class="-flair">" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</div> </td>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <td align="right" class="post-signature"> " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " <div class="user-info ">" & @CRLF & _ " <div class="user-action-time">" & @CRLF & _ " answered <span title="2016-03-23 19:20:30Z" class="relativetime">Mar 23 at 19:20</span>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-gravatar32">" & @CRLF & _ " <a href="/users/3836111/sebastian-proske"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/bc8e3526756540925b0536455b280205?s=32&amp;d=identicon&amp;r=PG&amp;f=1" alt="" width="32" height="32"></div></a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-details">" & @CRLF & _ " <a href="/users/3836111/sebastian-proske">Sebastian Proske</a>" & @CRLF & _ " <div class="-flair">" & @CRLF & _ " <span class="reputation-score" title="reputation score " dir="ltr">1,352</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="6 silver badges"><span class="badge2"></span><span class="badgecount">6</span></span><span title="16 bronze badges"><span class="badge3"></span><span class="badgecount">16</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ "</td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ "<tr>" & @CRLF & _ " <td class="votecell"></td>" & @CRLF & _ " <td>" & @CRLF & _ " <div id="comments-36186925" class="comments ">" & @CRLF & _ " <table>" & @CRLF & _ " <tbody data-remaining-comments-count="0"" & @CRLF & _ " data-canpost="false"" & @CRLF & _ " data-cansee="true"" & @CRLF & _ " data-comments-unavailable="false"" & @CRLF & _ " data-addlink-disabled="true">" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <tr id="comment-60010668" class="comment ">" & @CRLF & _ " <td>" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " &nbsp;&nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">Only seems to work in php</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/4425156/rapha%c3%abl"" & @CRLF & _ " title="133 reputation"" & @CRLF & _ " class="comment-user owner">Rapha&#235;l</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 20:06:54Z" class="relativetime-clean">Mar 23 at 20:06</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div id="comments-link-36186925" data-rep=50 data-anon=true>" & @CRLF & _ "" & @CRLF & _ " <a class="js-add-link comments-link disabled-link "" & @CRLF & _ " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”."" & @CRLF & _ " >add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span>" & @CRLF & _ " <a class="js-show-link comments-link dno" title="expand to show all comments on this post" href=# onclick=""></a>" & @CRLF & _ " </div> " & @CRLF & _ " </td>" & @CRLF & _ "</tr> </table>" & @CRLF & _ "</div>" & @CRLF & _ "<script>" & @CRLF & _ " var ados = ados || {}; ados.run = ados.run || [];" & @CRLF & _ " ados.run.push(function () { ados_add_placement(22,8277,"adzerk1282216698",4).setZone(44); });" & @CRLF & _ " </script>" & @CRLF & _ " <div class="everyonelovesstackoverflow" id="adzerk1282216698">" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ "<a name="36186022"></a>" & @CRLF & _ "<div id="answer-36186022" class="answer" data-answerid="36186022" itemscope itemtype="http://schema.org/Answer">" & @CRLF & _ " <table>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="votecell">" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<div class="vote">" & @CRLF & _ " <input type="hidden" name="_id_" value="36186022">" & @CRLF & _ " <a class="vote-up-off" title="This answer is useful">up vote</a>" & @CRLF & _ " <span itemprop="upvoteCount" class="vote-count-post ">1</span>" & @CRLF & _ " <a class="vote-down-off" title="This answer is not useful">down vote</a>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " </td>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "<td class="answercell">" & @CRLF & _ " <div class="post-text" itemprop="text">" & @CRLF & _ "<p>If you are planning to iterate anyways, I would consider iterating to grab all the things inside double-quotes first, using this regular expression:</p>" & @CRLF & _ "" & @CRLF & _ "<p>"(.*?)"</p>" & @CRLF & _ "" & @CRLF & _ "<p>This does a non-greedy (first) match of everything between a pair of quotation marks. </p>" & @CRLF & _ "" & @CRLF & _ "<p>(see other ways to grab things between quotation marks here: <a href="http://stackoverflow.com/questions/171480/regex-grabbing-values-between-quotation-marks">RegEx: Grabbing values between quotation marks</a>) </p>" & @CRLF & _ "" & @CRLF & _ "<p>Once you have all the strings inside pairs of double quotes, it will be trivial to match any single quote inside these strings.</p>" & @CRLF & _ " </div>" & @CRLF & _ " <table class="fw">" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="vt">" & @CRLF & _ "<div class="post-menu"><a href="/a/36186022" title="short permalink to this answer" class="short-link" id="link-post-36186022">share</a><span class="lsep">|</span><a href="/posts/36186022/edit" class="suggest-edit-post" title="">improve this answer</a></div> </td>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <td align="right" class="post-signature"> " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " <div class="user-info ">" & @CRLF & _ " <div class="user-action-time">" & @CRLF & _ " answered <span title="2016-03-23 18:28:12Z" class="relativetime">Mar 23 at 18:28</span>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-gravatar32">" & @CRLF & _ " <a href="/users/4901005/shane-bergsma"><div class="gravatar-wrapper-32"><img src="https://lh4.googleusercontent.com/-1IgA2AlHmtQ/AAAAAAAAAAI/AAAAAAAABRU/E9LgXoUQm-Q/photo.jpg?sz=32" alt="" width="32" height="32"></div></a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="user-details">" & @CRLF & _ " <a href="/users/4901005/shane-bergsma">Shane Bergsma</a>" & @CRLF & _ " <div class="-flair">" & @CRLF & _ " <span class="reputation-score" title="reputation score " dir="ltr">25</span><span title="6 bronze badges"><span class="badge3"></span><span class="badgecount">6</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ "</td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ "<tr>" & @CRLF & _ " <td class="votecell"></td>" & @CRLF & _ " <td>" & @CRLF & _ " <div id="comments-36186022" class="comments ">" & @CRLF & _ " <table>" & @CRLF & _ " <tbody data-remaining-comments-count="0"" & @CRLF & _ " data-canpost="false"" & @CRLF & _ " data-cansee="true"" & @CRLF & _ " data-comments-unavailable="false"" & @CRLF & _ " data-addlink-disabled="true">" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <tr id="comment-60007787" class="comment ">" & @CRLF & _ " <td>" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " &nbsp;&nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">I am currently working on doing that in Java, but it&#39;d still be nice to do and/or know how to do it using a regex !</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/4425156/rapha%c3%abl"" & @CRLF & _ " title="133 reputation"" & @CRLF & _ " class="comment-user owner">Rapha&#235;l</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 18:43:34Z" class="relativetime-clean">Mar 23 at 18:43</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr id="comment-60011002" class="comment ">" & @CRLF & _ " <td class="comment-actions">" & @CRLF & _ " <table>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class=" comment-score">" & @CRLF & _ " <span title="number of &#39;useful comment&#39; votes received"" & @CRLF & _ " class="cool">1</span>" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " &nbsp;" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="comment-text">" & @CRLF & _ " <div style="display: block;" class="comment-body">" & @CRLF & _ " <span class="comment-copy">Good point to be made here about what a regex is good for, because in a lot of cases it makes more sense to use your program to do the processing. A regex is not (practically) a programming language, it&#39;s one of (hopefully) many tools provided by a programming language.</span>" & @CRLF & _ " &ndash;&nbsp;<a href="/users/1255289/miken32"" & @CRLF & _ " title="7,846 reputation"" & @CRLF & _ " class="comment-user">miken32</a>" & @CRLF & _ " <span class="comment-date" dir="ltr"><span title="2016-03-23 20:17:02Z" class="relativetime-clean">Mar 23 at 20:17</span></span>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div id="comments-link-36186022" data-rep=50 data-anon=true>" & @CRLF & _ "" & @CRLF & _ " <a class="js-add-link comments-link disabled-link "" & @CRLF & _ " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”."" & @CRLF & _ " >add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span>" & @CRLF & _ " <a class="js-show-link comments-link dno" title="expand to show all comments on this post" href=# onclick=""></a>" & @CRLF & _ " </div> " & @CRLF & _ " </td>" & @CRLF & _ "</tr> </table>" & @CRLF & _ "</div>" & @CRLF & _ " <a name='new-answer'></a>" & @CRLF & _ " <form id="post-form" action="/questions/36183788/answer/submit" method="post" class="post-form">" & @CRLF & _ " <input type="hidden" id="post-id" value="36183788" />" & @CRLF & _ " <input type="hidden" id="qualityBanWarningShown" name="qualityBanWarningShown" value="false" />" & @CRLF & _ " <input type="hidden" name="referrer" value=""/>" & @CRLF & _ " <h2 class="space">Your Answer</h2>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <script>" & @CRLF & _ " StackExchange.ifUsing("editor", function () {" & @CRLF & _ " StackExchange.using("externalEditor", function () {" & @CRLF & _ " StackExchange.using("snippets", function () {" & @CRLF & _ " StackExchange.snippets.init();" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ " }, "code-snippets");" & @CRLF & _ " </script>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<script>" & @CRLF & _ " StackExchange.ready(function() {" & @CRLF & _ " initTagRenderer("".split(" "), "".split(" "));" & @CRLF & _ " " & @CRLF & _ " StackExchange.using("externalEditor", function() {" & @CRLF & _ " // Have to fire editor after snippets, if snippets enabled" & @CRLF & _ " if (StackExchange.options.snippets.enabled) {" & @CRLF & _ " StackExchange.using("snippets", function() {" & @CRLF & _ " createEditor();" & @CRLF & _ " });" & @CRLF & _ " }" & @CRLF & _ " else {" & @CRLF & _ " createEditor();" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ "" & @CRLF & _ " function createEditor() {" & @CRLF & _ " prepareEditor({" & @CRLF & _ " heartbeatType: 'answer'," & @CRLF & _ " convertImagesToLinks: true," & @CRLF & _ " reputationToPostImages: 10," & @CRLF & _ " bindNavPrevention: true," & @CRLF & _ " postfix: ""," & @CRLF & _ " onDemand: true," & @CRLF & _ " discardSelector: ".discard-answer"" & @CRLF & _ " ,immediatelyShowMarkdownHelp:true" & @CRLF & _ " });" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " }" & @CRLF & _ " }); " & @CRLF & _ "</script>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "<div id="post-editor" class="post-editor js-post-editor">" & @CRLF & _ "" & @CRLF & _ " <div style="position: relative;"> " & @CRLF & _ " <div class="wmd-container">" & @CRLF & _ " <div id="wmd-button-bar" class="wmd-button-bar"></div>" & @CRLF & _ " <textarea id="wmd-input" class="wmd-input" name="post-text" cols="92" rows="15" tabindex="101" data-min-length=""></textarea>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div class="fl" style="margin-top: 8px; height:24px;">&nbsp;</div>" & @CRLF & _ " <div id="draft-saved" class="draft-saved community-option fl" style="margin-top: 8px; height:24px; display:none;">draft saved</div>" & @CRLF & _ "" & @CRLF & _ " <div id="draft-discarded" class="draft-discarded community-option fl" style="margin-top: 8px; height:24px; display:none;">draft discarded</div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <div id="wmd-preview" class="wmd-preview"></div>" & @CRLF & _ " <div></div>" & @CRLF & _ " <div class="edit-block">" & @CRLF & _ " <input id="fkey" name="fkey" type="hidden" value="854f77cbe5f2c1ef88213c404c702005">" & @CRLF & _ " <input id="author" name="author" type="text">" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "</div>" & @CRLF & _ " <div style="position: relative;">" & @CRLF & _ " " & @CRLF & _ " <div class="form-item dno new-post-login">" & @CRLF & _ " " & @CRLF & _ " <div class="new-login-form">" & @CRLF & _ " <div class="new-login-left">" & @CRLF & _ " <h3>Sign up or <a id="login-link" href="/users/login?ssrc=question_page&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f36183788%2fregex-to-match-single-quotes-being-quoted-by-double-quotes%23new-answer">log in</a></h3>" & @CRLF & _ " <script>" & @CRLF & _ " StackExchange.ready(function () {" & @CRLF & _ " StackExchange.helpers.onClickDraftSave('#login-link');" & @CRLF & _ " });" & @CRLF & _ " </script>" & @CRLF & _ " <div class="preferred-login google-login">" & @CRLF & _ " <p><span class="icon"></span><span>Sign up using Google</span></p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="preferred-login facebook-login">" & @CRLF & _ " <p><span class="icon"></span><span>Sign up using Facebook</span></p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="preferred-login stackexchange-login">" & @CRLF & _ " <p><span class="icon"></span><span>Sign up using Email and Password</span></p>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <input type="hidden" name="manual-openid" class="manual-openid" />" & @CRLF & _ " <input type="hidden" name="use-facebook" class="use-facebook" value="false" />" & @CRLF & _ " <input type="hidden" name="use-google" class="use-google" value="false" />" & @CRLF & _ " <input type="button" class="submit-openid" value="Submit" style="display:none" />" & @CRLF & _ " <div class="new-login-right">" & @CRLF & _ " <h3>Post as a guest</h3>" & @CRLF & _ " <div class="form-item">" & @CRLF & _ " <table>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="vm">" & @CRLF & _ " <div>" & @CRLF & _ " <label for="display-name">Name</label>" & @CRLF & _ " <input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105">" & @CRLF & _ " </div>" & @CRLF & _ " <div>" & @CRLF & _ " <label for="m-address">Email</label>" & @CRLF & _ " <input id="m-address" name="m-address" type="email" size="30" maxlength="100" value="" tabindex="106" placeholder="required, but never shown" />" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <script>" & @CRLF & _ " StackExchange.ready(" & @CRLF & _ " function () {" & @CRLF & _ " StackExchange.openid.initPostLogin('.new-post-login', 'http%3a%2f%2fstackoverflow.com%2fquestions%2f36183788%2fregex-to-match-single-quotes-being-quoted-by-double-quotes%23new-answer', 'question_page');" & @CRLF & _ " }" & @CRLF & _ " );" & @CRLF & _ " </script>" & @CRLF & _ " <noscript>" & @CRLF & _ " <h3>Post as a guest</h3>" & @CRLF & _ " <div class="form-item">" & @CRLF & _ " <table>" & @CRLF & _ " <tr>" & @CRLF & _ " <td class="vm">" & @CRLF & _ " <div>" & @CRLF & _ " <label for="display-name">Name</label>" & @CRLF & _ " <input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105">" & @CRLF & _ " </div>" & @CRLF & _ " <div>" & @CRLF & _ " <label for="m-address">Email</label>" & @CRLF & _ " <input id="m-address" name="m-address" type="email" size="30" maxlength="100" value="" tabindex="106" placeholder="required, but never shown" />" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " </noscript>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " <div class="form-submit cbt">" & @CRLF & _ " <input id="submit-button" type="submit" value="Post Your Answer" tabindex="110">" & @CRLF & _ " <a href="#" class="btn-clear discard-answer dno">discard</a>" & @CRLF & _ "" & @CRLF & _ "<p class="privacy-policy-agreement">" & @CRLF & _ "By posting your answer, you agree to the <a href='http://stackexchange.com/legal/privacy-policy' target='_blank'>privacy policy</a> and <a href='http://stackexchange.com/legal/terms-of-service' target='_blank'>terms of service</a>.</p>" & @CRLF & _ "<input type="hidden" name="legalLinksShown" value="1" /> </div>" & @CRLF & _ " </form>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <h2 class="bottom-notice" data-loc="1">" & @CRLF & _ "Not the answer you&#39;re looking for? Browse other questions tagged <a href="/questions/tagged/java" class="post-tag" title="show questions tagged &#39;java&#39;" rel="tag">java</a> <a href="/questions/tagged/regex" class="post-tag" title="show questions tagged &#39;regex&#39;" rel="tag">regex</a> or <a href="/questions/ask">ask your own question</a>. </h2>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div id="sidebar" class="show-votes">" & @CRLF & _ " <div class="module question-stats">" & @CRLF & _ " <table id="qinfo">" & @CRLF & _ " <tr>" & @CRLF & _ " <td>" & @CRLF & _ " <p class="label-key">asked</p>" & @CRLF & _ " </td>" & @CRLF & _ " <td style="padding-left: 10px">" & @CRLF & _ " <p class="label-key" title="2016-03-23 16:35:05Z"><b>1 month ago</b></p>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td>" & @CRLF & _ " <p class="label-key">viewed</p>" & @CRLF & _ " </td>" & @CRLF & _ "" & @CRLF & _ " <td style="padding-left: 10px">" & @CRLF & _ " <p class="label-key">" & @CRLF & _ " <b>99 times</b>" & @CRLF & _ " </p>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td>" & @CRLF & _ " <p class="label-key">active</p>" & @CRLF & _ " </td>" & @CRLF & _ " <td style="padding-left: 10px">" & @CRLF & _ " <p class="label-key"><b><a href="?lastactivity" class="lastactivity-link" title="2016-03-23 19:26:36Z">1 month ago</a></b></p>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " <script>" & @CRLF & _ " var ados = ados || {}; ados.run = ados.run || [];" & @CRLF & _ " ados.run.push(function () { ados_add_placement(22,8277,"adzerk1688566301",[5,17,2221]).setZone(45); });" & @CRLF & _ " </script>" & @CRLF & _ " <div class="everyonelovesstackoverflow" id="adzerk1688566301">" & @CRLF & _ " </div>" & @CRLF & _ " <div id="hireme">" & @CRLF & _ " <script>" & @CRLF & _ ";"use strict";(function(n){function it(n,i,r){var u=t.createElement("script"),e="onreadystatechange",o="onload",f="readyState",s=!1;u.async=!0;u.src=n;typeof i=="function"&&(u[o]=u[e]=function(){s||u[f]&&u[f]!=="loaded"&&u[f]!=="complete"||(s=!0,typeof i=="function"&&i(u),u[o]=u[e]=null,r&&u.parentNode.removeChild(u))});ft.appendChild(u)}function rt(n){var i=t.createElement("link");i.type="text/css";i.rel="stylesheet";i.href=n;et.appendChild(i)}function ct(){var n=i.StackExchange,t="options",r="user";return n&&n[t]&&n[t][r]&&n[t][r].accountId}function lt(n){var t,i;return n=ot(f.hash?f.hash.substr(1):"",n||{}),t=n.ac||n.accountId||ct(),t&&(n.ac=t),n.tags||(i=tt(),i.length>0&&(n.tags=i.join(";"))),n.host=f.host.replace(/\.internal$/,""),n}function at(n,t,i,u){var c=h(n);if(c===null)return function(){};var e=null,f=null,l=r(),a=function a(){g(c)?(s(e),u(!1,r()-l)):f=o(a,t)};return f=o(a,t),i!==undefined&&(e=o(function(){s(f);u(!0,r()-l)},i)),function(){s(f);s(e)}}function vt(n){var u=f.hash.indexOf("large=1")!==-1,e=y(),o=u||!e||n,s=o?1:2,h=a(["hireme","clc-sb"],v),t=[s+"="+h],r=a(["careers1","clc-tlb"],v),i;return r&&t.push("5="+r),i=a(["careers3","clc-mlb"],v),i&&t.push("6="+i),t.join("&")}function ut(n,t){var e=!!h("#careersadsdoublehigh"),s=k({},u,{zones:u.zones||vt(e)}),f=lt(s),o;n&&(f.azt=1);t&&(f.lw=t);typeof i.innerWidth=="number"&&(f.bw=i.innerWidth);b&&(f.ver=b);o=p()-(e+0);o>0&&(f.az="1");var c=st(f,["zones","ip","ac","eng","prov","tags","theme","at","remote","seed","lw","azt","sysadmin","bw","nocpm","jobview","cpview","ver","host","cp","az"]),a=w+"?"+c;l=r();it(a)}function yt(n){function h(){f.forEach(rt);e.forEach(function(n){return pt(n,t[n],s,o)});typeof i.clc_after_load=="function"&&i.clc_after_load()}var t=n.cr,u=n.h,f=n.st,e=Object.keys(t),o=l?r()-l:0,s="//"+u+"/ct";h()}function pt(n,t,i,r){var s=t.cl,c=t.cn,f=t.an,l=t.tr,o=(s||[]).join(" "),u=h("#"+n);u&&(o&&(u.className+=" "+o),u.innerHTML=c.replace("&pt=0","&pt="+(r||0)),u.onmousedown=function(n){for(var t=n.target,r,o,s;t.tagName!=="A"&&t!==u;)t=t.parentNode;t!==u&&(r=[],f&&r.push("an="+f),o=[].filter.call(t.attributes,function(n){return/^data-/.test(n.name)}),o.length>0&&o.forEach(function(n){var t=n.name.replace(/^data-/,"");r.push(e(t)+"="+e(n.value))}),r.push("tr="+l),s="",r.length>0&&(s="?"+r.join("&")),t.href=i+s)})}function wt(n){var i=t.createElement("a");return i.href=n,i.host}function bt(){var i,n;y()?(n=at("#sidebar "+c,20,i,ut),o(function(){var r=h(c),i;g(r)||(r.parentNode.removeChild(r),typeof n=="function"&&n(),i=t.createElement("img"),i.src="//"+wt(w)+"/to.gif",i.style.display="none",t.body.appendChild(i))},2e3)):ut()}var w=n.u,u=n.o,b=n.c,y,p;u=u||{};var k=Object.assign||function(n){for(var i,r,t=1;t<arguments.length;t++){i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r])}return n},i=window,f=i.location,e=i.encodeURIComponent,d=i.decodeURIComponent,t=i.document,ft=t.body,et=t.getElementsByTagName("head")[0],o=i.setTimeout,s=i.clearTimeout,c="[id^=adzerk].everyonelovesstackoverflow",l=0,r=function(){return(new Date).getTime()},ot=function(n,t){return n.split(/\&/g).reduce(function(n,t){var i=t.split("=");return n[d(i[0])]=d(i[1]),n},t||{})},st=function(n,t){return Object.keys(n).filter(function(n){return t.indexOf(n)!==-1}).map(function(t){return e(t)+"="+e(n[t])}).join("&")},g=function(n){return n.innerHTML.replace(/\s+$/g,"")},nt=t.querySelectorAll.bind(t),h=t.querySelector.bind(t),ht=t.getElementById.bind(t),a=function(n,t){return n.filter(t)[0]},tt=function(){return[].map.call(nt(".post-taglist .post-tag"),function(n){return n.textContent})},v=function(n){return!!ht(n)};y=function(){return p()>0};p=function(){return nt(c).length};i.clc=k(window.clc||{},{init:yt,load:bt,ls:it,as:rt,tags:tt})}).call(null, {"c":"bbdb06f","u":"//clc.stackoverflow.com/p.js"});"use strict";var allowedHosts=["stackoverflow.com","serverfault.com"];(allowedHosts[0]==="*"||allowedHosts.indexOf(location.hostname)!==-1)&&window.clc.load(); </script>" & @CRLF & _ " </div>" & @CRLF & _ " <div style="margin-bottom: 10px;">" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<style type="text/css">" & @CRLF & _ "#newsletter-ad {" & @CRLF & _ " width: 270px;" & @CRLF & _ " height: 250px;" & @CRLF & _ " overflow: hidden;" & @CRLF & _ " background: url('//cdn.sstatic.net/Sites/stackoverflow/img/newsletter-ad.png?v=4');" & @CRLF & _ " padding: 0 15px 0 15px;" & @CRLF & _ "}" & @CRLF & _ "#newsletter-ad-header {" & @CRLF & _ " margin-top: 60px;" & @CRLF & _ "}" & @CRLF & _ "#newsletter-ad ul {" & @CRLF & _ " margin: 1em 0 1em 1.5em;" & @CRLF & _ "}" & @CRLF & _ "#newsletter-ad ul li {" & @CRLF & _ " margin-bottom: 5px;" & @CRLF & _ "}" & @CRLF & _ "#newsletter-signup-container {" & @CRLF & _ " text-align: center;" & @CRLF & _ "}" & @CRLF & _ "#newsletter-preview-container {" & @CRLF & _ " margin-top: 10px;" & @CRLF & _ " text-align: center;" & @CRLF & _ "}" & @CRLF & _ "#newsletter-email-input {" & @CRLF & _ " width: 200px;" & @CRLF & _ "}" & @CRLF & _ "</style>" & @CRLF & _ "" & @CRLF & _ "<script>" & @CRLF & _ " StackExchange.ready(function () {" & @CRLF & _ " StackExchange.newsletterAd.init();" & @CRLF & _ " });" & @CRLF & _ "</script>" & @CRLF & _ "" & @CRLF & _ "<div id="newsletter-ad">" & @CRLF & _ " <p id="newsletter-ad-header">Get the <b>weekly newsletter!</b> In it, you&#39;ll get:</p>" & @CRLF & _ " <ul>" & @CRLF & _ " <li>The week&#39;s top questions and answers</li>" & @CRLF & _ " <li>Important community announcements</li>" & @CRLF & _ " <li>Questions that need answers</li>" & @CRLF & _ " </ul>" & @CRLF & _ " <div id="newsletter-signup-container"><input id="newsletter-signup" type="button" value="Sign up for the newsletter" /></div>" & @CRLF & _ " <p id="newsletter-preview-container">see an <a href="//stackexchange.com/newsletters/newsletter?site=stackoverflow.com" id="newsletter-preview">example newsletter</a></p>" & @CRLF & _ " <div class="dno">" & @CRLF & _ " " & @CRLF & _ "<p class="privacy-policy-agreement">" & @CRLF & _ "By subscribing, you agree to the <a href='http://stackexchange.com/legal/privacy-policy' target='_blank'>privacy policy</a> and <a href='http://stackexchange.com/legal/terms-of-service' target='_blank'>terms of service</a>.</p>" & @CRLF & _ "<input type="hidden" name="legalLinksShown" value="1" />" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " </div> " & @CRLF & _ " " & @CRLF & _ " <div class="module sidebar-linked">" & @CRLF & _ " <h4 id="h-linked">Linked</h4>" & @CRLF & _ " <div class="linked" data-tracker="lq=1">" & @CRLF & _ "<div class="spacer">" & @CRLF & _ " <a href="/q/171480" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">74</div>" & @CRLF & _ " </a>" & @CRLF & _ " <a href="/questions/171480/regex-grabbing-values-between-quotation-marks" class="question-hyperlink">RegEx: Grabbing values between quotation marks</a>" & @CRLF & _ "</div> </div>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " <div class="module sidebar-related">" & @CRLF & _ " <h4 id="h-related">Related</h4>" & @CRLF & _ " <div class="related js-gps-related-questions" data-tracker="rq=1">" & @CRLF & _ " <div class="spacer">" & @CRLF & _ "<a href="/q/406230" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted extra-large">2233" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/406230/regular-expression-to-match-line-that-doesnt-contain-a-word" class="question-hyperlink">Regular expression to match line that doesn&#39;t contain a word?</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/6364105" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">9" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/6364105/regex-for-matching-quotes-and-single-quotes" class="question-hyperlink">Regex for matching quotes and single quotes</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/12401757" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">1" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/12401757/regex-for-matching-single-double-an-no-quotes" class="question-hyperlink">Regex for matching single,double an no quotes</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/12742232" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">0" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/12742232/regex-to-match-words-between-single-or-double-quotes-in-a-string" class="question-hyperlink">Regex to match words between single or double quotes in a string</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/17009265" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">0" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/17009265/replace-single-quote-with-double-quote-with-regex" class="question-hyperlink">Replace single quote with double quote with Regex</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/20263853" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">0" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/20263853/regex-match-double-single-quote-inside-string" class="question-hyperlink">Regex: Match double single quote inside string</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/21146610" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes default">1" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/21146610/javascript-regex-to-match-anything-between-single-quotes-double-quotes-and-rege" class="question-hyperlink">javascript regex to match anything between single quotes, double quotes and regex slashes</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/27775787" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">0" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/27775787/regex-to-match-single-quotes-within-double-quotes-separately" class="question-hyperlink">Regex to match single quotes within double quotes (separately)?</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/28237930" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">-1" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/28237930/regex-to-match-word-that-is-not-in-double-or-single-quotes" class="question-hyperlink">Regex to match word that is not in double or single quotes</a>" & @CRLF & _ "</div>" & @CRLF & _ "<div class="spacer">" & @CRLF & _ "<a href="/q/29018148" title="Vote score (upvotes - downvotes)">" & @CRLF & _ " <div class="answer-votes answered-accepted default">1" & @CRLF & _ " </div>" & @CRLF & _ "</a><a href="/questions/29018148/regex-to-replace-double-with-single-quotes-if-at-beginning-and-end-of-matching-s" class="question-hyperlink">Regex to replace double with single quotes if at beginning and end of matching string</a>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ "<div id="hot-network-questions" class="module">" & @CRLF & _ " <h4>" & @CRLF & _ " <a href="//stackexchange.com/questions?tab=hot" " & @CRLF & _ " class="js-gps-track" " & @CRLF & _ " data-gps-track="posts_hot_network.click({ item_type:1, location:11 })">" & @CRLF & _ " Hot Network Questions" & @CRLF & _ " </a>" & @CRLF & _ " </h4>" & @CRLF & _ " <ul>" & @CRLF & _ " <li >" & @CRLF & _ " <div class="favicon favicon-workplace" title="The Workplace Stack Exchange"></div><a href="http://workplace.stackexchange.com/questions/66738/gift-to-my-boss-and-manager-on-last-day" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:423 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Gift to my boss and manager on last day" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li >" & @CRLF & _ " <div class="favicon favicon-scifi" title="Science Fiction &amp; Fantasy Stack Exchange"></div><a href="http://scifi.stackexchange.com/questions/127528/what-is-the-object-in-the-opening-shot-of-the-force-awakens" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:186 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " What is the object in the opening shot of The Force Awakens?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li >" & @CRLF & _ " <div class="favicon favicon-stackoverflow" title="Stack Overflow"></div><a href="http://stackoverflow.com/questions/37114407/difference-between-template-parameters-typename-vs-non-typenames" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:1 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " difference between template parameters typename vs non typenames?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li >" & @CRLF & _ " <div class="favicon favicon-codegolf" title="Programming Puzzles &amp; Code Golf Stack Exchange"></div><a href="http://codegolf.stackexchange.com/questions/79644/how-many-steps-does-it-take-from-n-to-1-by-subtracting-the-greatest-divisor" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:200 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " How many steps does it take from n to 1 by subtracting the greatest divisor?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li >" & @CRLF & _ " <div class="favicon favicon-music" title="Music: Practice &amp; Theory Stack Exchange"></div><a href="http://music.stackexchange.com/questions/44276/why-do-instruments-have-a-key" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:240 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Why do instruments have a key?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-scifi" title="Science Fiction &amp; Fantasy Stack Exchange"></div><a href="http://scifi.stackexchange.com/questions/127460/why-is-the-laser-dish-in-the-southern-hemisphere-of-the-death-star-rather-than-t" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:186 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Why is the laser dish in the southern hemisphere of the Death Star rather than the northern one?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-movies" title="Movies &amp; TV Stack Exchange"></div><a href="http://movies.stackexchange.com/questions/52773/why-did-black-panther-not-kill-zemo" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:367 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Why did Black Panther not kill Zemo?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-rpg" title="Role-playing Games Stack Exchange"></div><a href="http://rpg.stackexchange.com/questions/79864/do-rage-and-uncanny-dodge-stack" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:122 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Do Rage and Uncanny Dodge stack?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-security" title="Information Security Stack Exchange"></div><a href="http://security.stackexchange.com/questions/122687/what-are-the-negative-aspects-of-creating-fake-security-footprints" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:162 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " What are the negative aspects of creating fake security footprints?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-programmers" title="Programmers Stack Exchange"></div><a href="http://programmers.stackexchange.com/questions/317966/wouldnt-it-be-beneficial-to-write-tests-during-code-review" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:131 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Wouldn&#39;t it be beneficial to write tests during code review?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-photo" title="Photography Stack Exchange"></div><a href="http://photo.stackexchange.com/questions/77235/why-buy-prime-super-telephoto-lenses-instead-of-zoom-super-telephoto-lenses" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:61 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Why buy prime super telephoto lenses instead of zoom super telephoto lenses?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-security" title="Information Security Stack Exchange"></div><a href="http://security.stackexchange.com/questions/122507/tracing-the-location-of-a-mobile-ip-from-an-email" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:162 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Tracing the location of a mobile IP from an email" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-puzzling" title="Puzzling Stack Exchange"></div><a href="http://puzzling.stackexchange.com/questions/32229/dont-try-this-at-home" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:559 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Don&#39;t try this at home" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-puzzling" title="Puzzling Stack Exchange"></div><a href="http://puzzling.stackexchange.com/questions/32251/im-a-legendary-story-so-who-am-i" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:559 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " I&#39;m a Legendary Story so who am I?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/1777344/how-many-non-differentiable-functions-exist" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " How many non-differentiable functions exist?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-codegolf" title="Programming Puzzles &amp; Code Golf Stack Exchange"></div><a href="http://codegolf.stackexchange.com/questions/79609/index-of-a-multidimensional-array" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:200 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Index of a multidimensional array" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-emacs" title="Emacs Stack Exchange"></div><a href="http://emacs.stackexchange.com/questions/22159/how-to-refactor-elisp-programs-using-pattern-matching-on-sexps-with-replacement" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:583 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " How to refactor elisp programs using pattern matching on sexps with replacement?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/1776904/what-is-the-smallest-number-of-people-in-a-group-so-that-it-is-guaranteed-that" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " What is the smallest number of people in a group, so that it is guaranteed that three of them will have their birthday in the same month?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-askubuntu" title="Ask Ubuntu"></div><a href="http://askubuntu.com/questions/769580/get-sudo-emails-for-specific-user" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:89 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Get `sudo` emails for specific user" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-english" title="English Language &amp; Usage Stack Exchange"></div><a href="http://english.stackexchange.com/questions/323803/jane-makes-over-six-figures-how-much-money-does-she-make" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:97 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " &quot;Jane makes over six figures&quot; - how much money does she make?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-movies" title="Movies &amp; TV Stack Exchange"></div><a href="http://movies.stackexchange.com/questions/52769/who-was-the-man-who-slew-the-kingsguard-knight" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:367 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Who was the man who slew the Kingsguard Knight?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-travel" title="Travel Stack Exchange"></div><a href="http://travel.stackexchange.com/questions/67963/how-can-i-tell-a-deutsche-bahn-train-has-a-supplementary-charge" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:273 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " How can I tell a Deutsche Bahn train has a supplementary charge?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-space" title="Space Exploration Stack Exchange"></div><a href="http://space.stackexchange.com/questions/15198/would-falcon-9-sink-on-gentle-splashdown" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:508 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Would Falcon 9 sink on gentle splashdown?" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " <li class="dno js-hidden">" & @CRLF & _ " <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="http://tex.stackexchange.com/questions/308697/braces-around-both-sides-of-cases-with-text" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })">" & @CRLF & _ " Braces around both sides of cases (with text)" & @CRLF & _ " </a>" & @CRLF & _ "" & @CRLF & _ " </li>" & @CRLF & _ " </ul>" & @CRLF & _ "" & @CRLF & _ " <a href="#" " & @CRLF & _ " class="show-more js-show-more js-gps-track" " & @CRLF & _ " data-gps-track="posts_hot_network.click({ item_type:3, location:11 })">" & @CRLF & _ " more hot questions" & @CRLF & _ " </a>" & @CRLF & _ "</div>" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ "<div id="feed-link">" & @CRLF & _ " <div id="feed-link-text">" & @CRLF & _ " <a href="/feeds/question/36183788" title="feed of this question and its answers">" & @CRLF & _ " <span class="feed-icon"></span>question feed" & @CRLF & _ " </a>" & @CRLF & _ " </div>" & @CRLF & _ "</div> <script>" & @CRLF & _ "StackExchange.ready(function(){$.get('/posts/36183788/ivc/e809');});" & @CRLF & _ "</script>" & @CRLF & _ "<noscript>" & @CRLF & _ " <div><img src="/posts/36183788/ivc/e809" class="dno" alt="" width="0" height="0"></div>" & @CRLF & _ "</noscript><div style="display:none" id="prettify-lang">lang-java</div></div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div id="footer" class="categories">" & @CRLF & _ " <div class="footerwrap">" & @CRLF & _ " <div id="footer-menu">" & @CRLF & _ " <div class="top-footer-links">" & @CRLF & _ " <a href="http://stackoverflow.com/company/about">about us</a>" & @CRLF & _ " <a href="/tour">tour</a>" & @CRLF & _ " <a href="/help">help</a>" & @CRLF & _ " <a href="http://blog.stackoverflow.com?blb=1">blog</a>" & @CRLF & _ " <a href="http://chat.stackoverflow.com">chat</a>" & @CRLF & _ " <a href="http://data.stackexchange.com">data</a>" & @CRLF & _ " <a href="http://stackexchange.com/legal">legal</a>" & @CRLF & _ " <a href="http://stackexchange.com/legal/privacy-policy">privacy policy</a>" & @CRLF & _ " <a href="http://stackoverflow.com/company/work-here">work here</a>" & @CRLF & _ " <a href="http://stackexchange.com/mediakit">advertising info</a>" & @CRLF & _ "" & @CRLF & _ " <a onclick='StackExchange.switchMobile("on")'>mobile</a>" & @CRLF & _ " <b><a href="/contact">contact us</a></b>" & @CRLF & _ " <b><a href="http://meta.stackoverflow.com">feedback</a></b>" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <div id="footer-sites">" & @CRLF & _ " <table>" & @CRLF & _ " <tr>" & @CRLF & _ " <th colspan=3>" & @CRLF & _ " Technology" & @CRLF & _ " </th>" & @CRLF & _ " <th >" & @CRLF & _ " Life / Arts" & @CRLF & _ " </th>" & @CRLF & _ " <th >" & @CRLF & _ " Culture / Recreation" & @CRLF & _ " </th>" & @CRLF & _ " <th >" & @CRLF & _ " Science" & @CRLF & _ " </th>" & @CRLF & _ " <th >" & @CRLF & _ " Other" & @CRLF & _ " </th>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td>" & @CRLF & _ " <ol>" & @CRLF & _ " <li><a href="//stackoverflow.com" title="professional and enthusiast programmers">Stack Overflow</a></li>" & @CRLF & _ " <li><a href="//serverfault.com" title="system and network administrators">Server Fault</a></li>" & @CRLF & _ " <li><a href="//superuser.com" title="computer enthusiasts and power users">Super User</a></li>" & @CRLF & _ " <li><a href="//webapps.stackexchange.com" title="power users of web applications">Web Applications</a></li>" & @CRLF & _ " <li><a href="//askubuntu.com" title="Ubuntu users and developers">Ask Ubuntu</a></li>" & @CRLF & _ " <li><a href="//webmasters.stackexchange.com" title="pro webmasters">Webmasters</a></li>" & @CRLF & _ " <li><a href="//gamedev.stackexchange.com" title="professional and independent game developers">Game Development</a></li>" & @CRLF & _ " <li><a href="//tex.stackexchange.com" title="users of TeX, LaTeX, ConTeXt, and related typesetting systems">TeX - LaTeX</a></li>" & @CRLF & _ " </ol></td><td><ol>" & @CRLF & _ " <li><a href="//programmers.stackexchange.com" title="professional programmers interested in conceptual questions about software development">Programmers</a></li>" & @CRLF & _ " <li><a href="//unix.stackexchange.com" title="users of Linux, FreeBSD and other Un*x-like operating systems">Unix &amp; Linux</a></li>" & @CRLF & _ " <li><a href="//apple.stackexchange.com" title="power users of Apple hardware and software">Ask Different (Apple)</a></li>" & @CRLF & _ " <li><a href="//wordpress.stackexchange.com" title="WordPress developers and administrators">WordPress Development</a></li>" & @CRLF & _ " <li><a href="//gis.stackexchange.com" title="cartographers, geographers and GIS professionals">Geographic Information Systems</a></li>" & @CRLF & _ " <li><a href="//electronics.stackexchange.com" title="electronics and electrical engineering professionals, students, and enthusiasts">Electrical Engineering</a></li>" & @CRLF & _ " <li><a href="//android.stackexchange.com" title="enthusiasts and power users of the Android operating system">Android Enthusiasts</a></li>" & @CRLF & _ " <li><a href="//security.stackexchange.com" title="information security professionals">Information Security</a></li>" & @CRLF & _ " </ol></td><td><ol>" & @CRLF & _ " <li><a href="//dba.stackexchange.com" title="database professionals who wish to improve their database skills and learn from others in the community">Database Administrators</a></li>" & @CRLF & _ " <li><a href="//drupal.stackexchange.com" title="Drupal developers and administrators">Drupal Answers</a></li>" & @CRLF & _ " <li><a href="//sharepoint.stackexchange.com" title="SharePoint enthusiasts">SharePoint</a></li>" & @CRLF & _ " <li><a href="//ux.stackexchange.com" title="user experience researchers and experts">User Experience</a></li>" & @CRLF & _ " <li><a href="//mathematica.stackexchange.com" title="users of Mathematica">Mathematica</a></li>" & @CRLF & _ " <li><a href="//salesforce.stackexchange.com" title="Salesforce administrators, implementation experts, developers and anybody in-between">Salesforce</a></li>" & @CRLF & _ " <li><a href="//expressionengine.stackexchange.com" title="administrators, end users, developers and designers for ExpressionEngine&#174; CMS">ExpressionEngine&#174; Answers</a></li>" & @CRLF & _ " " & @CRLF & _ " <li>" & @CRLF & _ " <a href="http://stackexchange.com/sites#technology" class="more">" & @CRLF & _ " more (13)" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " </ol>" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " <ol>" & @CRLF & _ " <li><a href="//photo.stackexchange.com" title="professional, enthusiast and amateur photographers">Photography</a></li>" & @CRLF & _ " <li><a href="//scifi.stackexchange.com" title="science fiction and fantasy enthusiasts">Science Fiction &amp; Fantasy</a></li>" & @CRLF & _ " <li><a href="//graphicdesign.stackexchange.com" title="Graphic Design professionals, students, and enthusiasts">Graphic Design</a></li>" & @CRLF & _ " <li><a href="//movies.stackexchange.com" title="movie and tv enthusiasts">Movies &amp; TV</a></li>" & @CRLF & _ " <li><a href="//cooking.stackexchange.com" title="professional and amateur chefs">Seasoned Advice (cooking)</a></li>" & @CRLF & _ " <li><a href="//diy.stackexchange.com" title="contractors and serious DIYers">Home Improvement</a></li>" & @CRLF & _ " <li><a href="//money.stackexchange.com" title="people who want to be financially literate">Personal Finance &amp; Money</a></li>" & @CRLF & _ " <li><a href="//academia.stackexchange.com" title="academics and those enrolled in higher education">Academia</a></li>" & @CRLF & _ " " & @CRLF & _ " <li>" & @CRLF & _ " <a href="http://stackexchange.com/sites#lifearts" class="more">" & @CRLF & _ " more (9)" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " </ol>" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " <ol>" & @CRLF & _ " <li><a href="//english.stackexchange.com" title="linguists, etymologists, and serious English language enthusiasts">English Language &amp; Usage</a></li>" & @CRLF & _ " <li><a href="//skeptics.stackexchange.com" title="scientific skepticism">Skeptics</a></li>" & @CRLF & _ " <li><a href="//judaism.stackexchange.com" title="those who base their lives on Jewish law and tradition and anyone interested in learning more">Mi Yodeya (Judaism)</a></li>" & @CRLF & _ " <li><a href="//travel.stackexchange.com" title="road warriors and seasoned travelers">Travel</a></li>" & @CRLF & _ " <li><a href="//christianity.stackexchange.com" title="committed Christians, experts in Christianity and those interested in learning more">Christianity</a></li>" & @CRLF & _ " <li><a href="//gaming.stackexchange.com" title="passionate videogamers on all platforms">Arqade (gaming)</a></li>" & @CRLF & _ " <li><a href="//bicycles.stackexchange.com" title="people who build and repair bicycles, people who train cycling, or commute on bicycles">Bicycles</a></li>" & @CRLF & _ " <li><a href="//rpg.stackexchange.com" title="gamemasters and players of tabletop, paper-and-pencil role-playing games">Role-playing Games</a></li>" & @CRLF & _ " " & @CRLF & _ " <li>" & @CRLF & _ " <a href="http://stackexchange.com/sites#culturerecreation" class="more">" & @CRLF & _ " more (21)" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " </ol>" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " <ol>" & @CRLF & _ " <li><a href="//math.stackexchange.com" title="people studying math at any level and professionals in related fields">Mathematics</a></li>" & @CRLF & _ " <li><a href="//stats.stackexchange.com" title="people interested in statistics, machine learning, data analysis, data mining, and data visualization">Cross Validated (stats)</a></li>" & @CRLF & _ " <li><a href="//cstheory.stackexchange.com" title="theoretical computer scientists and researchers in related fields">Theoretical Computer Science</a></li>" & @CRLF & _ " <li><a href="//physics.stackexchange.com" title="active researchers, academics and students of physics">Physics</a></li>" & @CRLF & _ " <li><a href="//mathoverflow.net" title="professional mathematicians">MathOverflow</a></li>" & @CRLF & _ " <li><a href="//chemistry.stackexchange.com" title="scientists, academics, teachers and students">Chemistry</a></li>" & @CRLF & _ " <li><a href="//biology.stackexchange.com" title="biology researchers, academics, and students">Biology</a></li>" & @CRLF & _ " " & @CRLF & _ " <li>" & @CRLF & _ " <a href="http://stackexchange.com/sites#science" class="more">" & @CRLF & _ " more (5)" & @CRLF & _ " </a>" & @CRLF & _ " </li>" & @CRLF & _ " </ol>" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " <ol>" & @CRLF & _ " <li><a href="//stackapps.com" title="apps, scripts, and development with the Stack Exchange API">Stack Apps</a></li>" & @CRLF & _ " <li><a href="//meta.stackexchange.com" title="meta-discussion of the Stack Exchange family of Q&amp;A websites">Meta Stack Exchange</a></li>" & @CRLF & _ " <li><a href="//area51.stackexchange.com" title="proposing new sites in the Stack Exchange network">Area 51</a></li>" & @CRLF & _ " <li><a href="//careers.stackoverflow.com">Stack Overflow Careers</a></li>" & @CRLF & _ " " & @CRLF & _ " </ol>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ "</table>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div id="copyright">" & @CRLF & _ " site design / logo &#169; 2016 Stack Exchange Inc; user contributions licensed under <a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="license">cc by-sa 3.0</a> " & @CRLF & _ " with <a href="http://blog.stackoverflow.com/2009/06/attribution-required/" rel="license">attribution required</a>" & @CRLF & _ " </div>" & @CRLF & _ " <div id="svnrev">" & @CRLF & _ " rev 2016.5.9.3554" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <noscript>" & @CRLF & _ " <div id="noscript-warning">Stack Overflow works best with JavaScript enabled<img src="http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" alt="" class="dno"></div>" & @CRLF & _ " </noscript>" & @CRLF & _ "<script>var p = "http", d = "static"; if (document.location.protocol == "https:") { p += "s"; d = "engine"; } var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = p + "://" + d + ".adzerk.net/ados.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script>" & @CRLF & _ "<script>" & @CRLF & _ " var ados = ados || {};" & @CRLF & _ " ados.run = ados.run || [];" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " ados.run.push(function () {" & @CRLF & _ " setTimeout(function () { $("#adzerk-user-match").remove(); }, window.AUMIframeDone ? 0 : 2000);" & @CRLF & _ " ados_setKeywords('java,regex');; ados_load();" & @CRLF & _ " }); " & @CRLF & _ " " & @CRLF & _ "</script>" & @CRLF & _ "" & @CRLF & _ " <script>" & @CRLF & _ " (function (i, s, o, g, r, a, m) {" & @CRLF & _ " i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o)," & @CRLF & _ " m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m);" & @CRLF & _ " })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');" & @CRLF & _ " ga('create', 'UA-5620270-1');" & @CRLF & _ " ga('set', 'dimension2', '|java|regex|'); ga('send', 'pageview');" & @CRLF & _ " var _qevents = _qevents || []," & @CRLF & _ " _comscore = _comscore || [];" & @CRLF & _ " (function () {" & @CRLF & _ " var ssl='https:'==document.location.protocol," & @CRLF & _ " s=document.getElementsByTagName('script')[0]," & @CRLF & _ " qc=document.createElement('script');" & @CRLF & _ " qc.async=true;" & @CRLF & _ " qc.src=(ssl?'https://secure':'http://edge')+'.quantserve.com/quant.js';" & @CRLF & _ " s.parentNode.insertBefore(qc, s);" & @CRLF & _ " var sc=document.createElement('script');" & @CRLF & _ " sc.async=true;" & @CRLF & _ " sc.src=(ssl?'https://sb':'http://b') + '.scorecardresearch.com/beacon.js';" & @CRLF & _ " s.parentNode.insertBefore(sc, s);" & @CRLF & _ " })();" & @CRLF & _ " _comscore.push({ c1: "2", c2: "17440561" });" & @CRLF & _ " _qevents.push({ qacct: "p-c1rF4kxgLUzNc" });" & @CRLF & _ " </script>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " </body>" & @CRLF & _ "</html>" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm