Matching entire string in gtksourceview

Issue Take this short XML snippet for defining strings in gtksourceview: <context id=”string” style-ref=”string” end-at-line-end=”true”> <start>”</start> <end>”</end> <include> <context id=”special-string” style-ref=”special”> <match>(foo|bar)</match> </context> <context ref=”def:line-continue”/> </include> </context> This highlights any instances of “foo” or “bar” inside a string. Suppose I

Continue reading

A better way to do replacement tags in c#?

Issue I need a better way to do this: Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(textMessage.Trim(), “{birthday}”, person.Birthday, RegexOptions.None), “{phone}”, person.MobilePhone, RegexOptions.None), “{email}”, person.Email, RegexOptions.None), “{lastname}”, person.LastName, RegexOptions.None), “{firstname}”, person.FirstName, RegexOptions.None) Solution textMessage.Trim() .Replace(“{birthday}”,person.Birthday) .Replace(“{phone}”,person.Phone) … Answered By – Reza ArabQaeni Answer Checked By – Gilberto

Continue reading

Need to match <template>(anything)</template>

Issue Here’s the problem, The match must not also match (anything) (anything), only the first set. Here’s jsFiddle where I’ve been trouble shooting this. http://jsfiddle.net/UFTR2/ var templates = ‘<template mini-dash-ytd>’+ ‘<span class=”mini-dash-title”>{{title}}</span>’+ ‘<span class=”mini-dash-metric”>{{value}}</span>’+ ‘</template>’+ ‘<template mini-dash-yesterday>’+ ‘<span class=”mini-dash-title”>{{title}}</span>’+ ‘<span

Continue reading

Php regex: replacing localization string

Issue The Stackoverflow user Casimir et Hippolyte gave me this awesome function to replace strings like [[ Something ]] with localized strings being returned with $this->_() function. $that = $this; $view = preg_replace_callback(‘~\[\[\K(?>[^]]++|](?!]))*~’, function ($m) use ($that) { return $that->__($m[0]);

Continue reading

Template string from regex

Issue Let’s say that I have the following URL path: /api/resource/:id Given the context object {id: 1} the path will be transformed to /api/resource/1. Now I want to build a more complex path template: /api/resource/:id(/relationships/:name)? Here the relationships member is

Continue reading

ng-pattern issue with input type number

Issue I am facing one weird issue when trying to use ng-pattern with input type number. <input type=”number” name=”input” min=”0″ max=”1000″ data-ng-model=”input” ng-pattern=”/^[0-9]*$/”> <div data-ng-if=”Form.input.$error.pattern”>Please enter an Integer number between 0 and 1000.</div> </div> As per my regular expression defined,

Continue reading

spicy angularjs regex

Issue I’ve been working on a regex problem for angularJs ng-pattern which needs: Cannot be blanks A minimum of 1 character and a maximum of 32 characters Spaces ONLY are not allowed Acceptable special characters(!@#$%&*-+=[]:;’,.? ) The answer is not

Continue reading

regex for multiple IPs comma separated with or without subnet

Issue I have regex for IPv4 address: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ and i have regex for IPv4 CIDR range : ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(/([0-9]|[1-2][0-9]|3[0-2]))$ the issue is how should i repeat it using comma separated pattern: XXX.XXX.XXX.XXX, XXX.XXX.XXX.XXX/XX, XX.XX.XX.XX, XX.XX.XX.XX/X , XX.XX.XX.X test data– 123.123.13.11, 1.0.0.0,

Continue reading

Regex to split a long expressions string into an array of individual expressions

Issue I have an expression string from Angular [ngClass] directive containing multiple expressions with their corresponding key separated by a comma. ‘background_orange’:row.columnname.split(‘,’)[4] == 1,’red:color’:test===’testname’,’yellow:color’:test===’testname’ When I try to split the above expression string into an array of individual expression with

Continue reading

Redirecting captured regex group using nginx

Issue With the following nginx location directive location ~* (.*)(\/graphql)$ { proxy_pass http://my-backend:80/$2; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; } I expect that URLs like https://example.com/anything/graphql is redirected to http://my-backend:80/$2 but that’s not the case

Continue reading

string search returning 0

Issue I created a regex using minimatch library in nodeJs. I wanted to find Date’s in the string. minimatch.makeRe("*/*/*") It returned /^(?:(?!\.)(?=.)[^/]*?\/(?!\.)(?=.)[^/]*?\/(?!\.)(?=.)[^/]*?)$/ But when I use the regex in string.search method it is returning 0. let text = "Some Test

Continue reading

Ignore periods and commas of RegExp

Issue I have a RegExp like so: const keywordsClone = […alert?.keywords]; keywordsClone.sort((a, b) => (a.length > b.length ? -1 : 1)); let transcript = alert?.transcript; forEach(keywordsClone, (k) => { const regExpression = new RegExp(`(${k})`, ‘ig’); //now it has exact match

Continue reading