asked    Ula     2018-10-22       javascript       25 view        2 Answers

[SOLVED] Regex match string which does not fully consist of angular expressions

I've the pleasure to find all strings in our projects which are not angularjs expressions because we're going multi language (so every string which is not fully between curly braces).

What I wanna do is build a regex which matches all strings, which have no angular expressions (or part of the string is no angular expression).

The var names describe which should match (yes) and which shouldn't (nope).

var yes = "test";
var nope = "{{xyz}}";
var yes = "test {{xyz}}";
var nope = "{{::xyz}}";
var nope = "{{xyz}} {{abc}}"; //as whitespace is okay

Tried a lot of different stuff using negative lookaheads etc. but ended up with a not even close working regex.


Maybe somebody can help me, as my head is like to explode...


  2 Answers  

        answered    Deborah     2018-10-22      

You may use following regex for match:


RegEx Demo

RegEx Details:

  • ": Match start quote
  • (?:: Start non-capture group
    • \s*{{[^\s}]*}}\s*: Match {{...}} string surrounded by optional whitespaces.
  • )+: End non-capture group. + matches 1 or more of this group
  • ": Match end quote

        answered    Otis     2018-10-22      

Thanks to anubhava as his post and explanation helped me creating this regex here:


var yes = "test";
var nope = "{{xyz}}";
var yes = "test {{xyz}}";
var yes = "{test";
var yes = "{test} bearbeiten";
var yes = "{test}";
var nope = "{{::xyz}}";
var nope = "{{xyz}} {{abc}}";
var yes = "{{xyz}} test {{abc}}";
var yes = "{{xyz}} test {{abc}} temp {{var}}";

Your Answer

 2018-10-22         Stacey

Inject User Credentials from HttpRequestContext into the service layer

I have a .NET 4.6 WebApi 2.0 OWIN App that serves HTTP Requests.Those requests are authenticated and we are storing certain claims in the RequestContext ClaimsIdentity (UserId, Client Code)We also have our Controllers, Services and Repository structure.Our Services are injected into the Controllers via Ninject, and the Repositories into the Services.When the user performers certain requests we need to check their permissions. The service usually needs to know the: UserId, ClientCode, Groups the user has access to and permissions under each group (Read, Write, etc). This las...
 c#                     2 answers                     102 view
 2018-10-22         Omar

File.Exists returns true on file name only

I am currently debugging an application, where the following code returns true on the file name only. If Not IO.File.Exists(out) Then '' WorkEnd IfThe watches for this execution is as follows:How is this statement validated as true, when the actual file is located fairly deep on a network drive? I'd assume that this could be true, if the file was located in the same directory as my execution. Documentation: File.Exists the path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the curren...
 .net                     1 answers                     102 view
 2018-10-22         Clement

Scrolling in ListView loses text color and typeface

I'm not sure why it's not working, but what my code should do is very simple.I have a ListView with default text color (BLACK) and typeface (MONOSPACE) that I declared in getView(), so everything works well when the view is created.When I select an item from the list it should change the text color to RED and the typeface to MONOSPACE and BOLD, and if I click another item, it will change that item to RED and BOLD and return the previous text to BLACK and NORMAL. This works just fine, but if I scroll away from the RED and BOLD text until it's not visible, and then scroll bac...
 java                     1 answers                     102 view