[Solved] Regex expression symbol without space

I would use: ~\{\{([^}]+?)\}\}~ and accessing array depends on your language! [EDIT] add explanations ~: delimiter \{\{, \}\}~: match characters literally. Should be escaped. [^}]: match anything inside {{}} until a } +: repeat pattern multiple times (for multiple characters) ?: is for ‘lazy’ to match as few times as possible. (): is to capture … Read more

[Solved] Parts of string in regex

This should get you started: var myUrl = “wmq://aster-C1.it.google.net@EO_B2:1427/QM.0021?queue=SOMEQueue?”; var myRegex = new Regex(@”wmq://(.*?)@(.*?)\?queue=(.*?)\?”); var myMatches = myRegex.Match(myUrl); Debug.Print(myMatches.Groups[1].Value); Debug.Print(myMatches.Groups[2].Value); Debug.Print(myMatches.Groups[3].Value); But you may need to change it a bit for variations in the url. There are proper tutorials on the web to explain Regex, but here is some quick info: @ before a string … Read more

[Solved] Regex to match url not for certain file types

You need to use a lookbehind for that, try http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=;]*)?(?<!jpg)(?<!gif)(?<!doc)$ You need also the anchor $ at the end, it matches the end of the string, that is important to define clearly the point from where the lookbehind should look behind. See it here on Regexr 1 solved Regex to match url not for … Read more

[Solved] Regexp to find only inner p tags inside the p tags

If your regex flavor supports lookarounds, try something like this: (?s)<p>(?:(?!</?p>).)*</p>(?=(?:(?!</?p>).|<p>(?:(?!</?p>).)*</p>)*?</p>) This part (?:(?!</?p>).)* assures, that there’s no opening or closing <p within. The positive lookahead at the end (?=… checks for being inside </p. See demo for trying at regex101. Generally regex is not the means for parsing html. What regex did you try … Read more

[Solved] Regular Expression to remove leading and trailing Angle Brackets

Why do you need to use Regex for this? You can simply do this: string email = “<[email protected]>”; email = email.TrimStart(‘<‘).TrimEnd(‘>’); Of course if you really need to be sure there’s no spaces, or that there might be multiple spaces: string email = “<[email protected]>”; email = email.Trim().TrimStart(‘<‘).TrimEnd(‘>’); solved Regular Expression to remove leading and trailing … Read more

[Solved] Make “automatic” corrections on failed groups matching

You can do it using a replacement map, replacing the character at index 1 if the given code doesn’t start with two letters: using System; using System.Text; using System.Collections.Generic; using System.Text.RegularExpressions; public class Test { private static string[] productCodes = new[] { “MD0133776311I”, “M10133776311I”, “M20133776311I” }; private static Dictionary<char, char> replacementMap = new Dictionary<char, char> … Read more

[Solved] Regex Help need to pull NFL Team name from a string

(=[A-Z])(\w|\%20|\.)+ This will capture only the team names and the space characters between them, with leading “=”. Then you can replace “%20″ with ” ” and split the resultant string along “=” so you’ll have a list of strings, each separately a team name. At least, that’s what I’d do in Python. Not sure what … Read more

[Solved] Regex to remove white spaces [closed]

I assume that you’re using php, based on that, try this: <? $text = “#id .class .anotherclass { color: #555 } #anotherid .class { color : #fff; }”; function removespaces($matches) { return $matches[1].str_replace(” “, “”, $matches[2]); } echo preg_replace_callback( “/(#.*?)(\{.*?\})/i”, “removespaces”, $text); ?> DEMO: http://ideone.com/T5Qzc6 solved Regex to remove white spaces [closed]