[Solved] Pull out replaceable fields from a string [closed]

static void Main(string[] args) { String str = “{dog} and the {cat}”; String[] ret = ExtractTagValue(str); } public static String[] ExtractTagValue(String input) { List<String> retLst = new List<string>(); String pattern = “(\\{.*?\\})”; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern); System.Text.RegularExpressions.MatchCollection matches = regex.Matches(input); if (matches.Count > 0) { foreach (Match match in matches) { retLst.Add(match.Value); } } … Read more

[Solved] How take the string between two symbols c#? [closed]

I’m not sure if this matches what you need but you could try: var myString = “!re=.id=2CB=name=xxname123=service=vpn=caller-id=”; var match = new Regex(@”\.id=(?<value>[^=]*)=”).Match(myString); var id = match.Groups[“value”].Value; I haven’t tested this for specific syntax, but that should get you just that captured string. You can modify that to iterate across a MatchCollection if you need to … Read more

[Solved] How can I get the string between two tags [closed]

use this pattern: @”\[video.*?\](.*?)\[/video\]” and then get group 1. I won’t post the whole code because I dont want to do your work for you. Read about C# Regexes, Patterns and try to write your code with this pattern. 1 solved How can I get the string between two tags [closed]

[Solved] Replacing a substring with given form with another in C#

Basically: take the pattern (containing 3 groups), replace instr with second group from pattern. private string MyReplace(string inStr, string leaveStr) { string pattern = @”(.*?)(” + leaveStr + “)(.*)”; string repl = @”*$2*”; Regex rgx = new Regex(pattern); return rgx.Replace(inStr, repl); } string x = MyReplace(@”\textbf\{atext\}”, “atext”); x = MyReplace(@”\textbf\{1\}”, “1”); full string – group … Read more

[Solved] Regular expression to match the string [closed]

Here’s one of many ways to get it: >>> x = r”'”self.unsupported_cmds = [r’\s*clns\s+routing’,””’ >>> print x “self.unsupported_cmds = [r’\s*clns\s+routing’,” >>> import re >>> pattern = re.escape(x) >>> re.match(pattern, x) <_sre.SRE_Match object at 0x7ffca3f66098> >>> print pattern \”self\.unsupported\_cmds\ \=\ \[r\’\\s\*clns\\s\+routing\’\,\” solved Regular expression to match the string [closed]

[Solved] Regular Expressions pattern to extract particular digits from text [closed]

Try this: \b(?:256\d{9}|07[17-9]\d{8})\b Explanation: <!– \b(?:256\d{9}|07[17-9]\d{8})\b Options: ^ and $ match at line breaks; free-spacing Assert position at a word boundary «\b» Match the regular expression below «(?:256\d{9}|07[17-9]\d{8})» Match either the regular expression below (attempting the next alternative only if this one fails) «256\d{9}» Match the characters “256” literally «256» Match a single digit 0..9 … Read more

[Solved] How to write Regex for input values? [closed]

var a=”123/4″; var b = ‘e123/4’; Variant 1 var regex = new RegExp(‘^[0-9/]+$’); console.log((a.match(regex)) ? true : false); // true console.log((b.match(regex)) ? true : false); // false Variant 2 var regex = /^[0-9/]+$/; console.log((a.match(regex)) ? true : false); // true console.log((b.match(regex)) ? true : false); // false Variant 3 var regex = /^[\d\/]+$/; console.log((a.match(regex)) ? … Read more

[Solved] How set found text in variable in Perl

Use captures ((…)). if ( my ($capture) = $x =~ /(NY)/ ) { say $capture; } By the way, always use use strict; use warnings qw( all );. The above program also needs use feature qw( say );. solved How set found text in variable in Perl

[Solved] how can i split the string with the cammas that are not embeded in braces , brackets and qutations from a string with php [closed]

One way would be to use lookarounds: <?php $data = <<<DATA func(‘name’,’family,address’) , “lorem ipsom, is a…” , [‘name’,’part’] DATA; $regex = ‘~(?<=\ ),(?=\h)~’; $parts = preg_split($regex, $data); print_r($parts); ?> See a working demo on ideone.com. Even better yet would be a (*SKIP)(*FAIL) mechanism: <?php $data = <<<DATA func(‘name’,’family,address’) , “lorem ipsom, is a…” , … Read more