Tag Archives: regex

Java Regex all non word characters except whitespace

Questions: This has Probably been asked before, but i want to split a string at every non word character except the white space in java. i do not have experience with regex in general and the wiki doesn’t really help. I’ve tried it with this: “[\\W][^\\s]” but that did not help. Edit: how the String… Read More »

C# Regex String Array escape *

Questions: I have this string Array of file extensions: public string[] mimeArray = new string[] { “text / plain”, @”text / htmlmultipart/.*”, “application/octet-stream”, @”application/.*”, @”text/.*”, @”image/.*”, @”audio/.*”, @”video/.*” };}; My Regex are not working properly, it’s taking: “text / plain”, “text / htmlmultipart\\”, “application/octet-stream”, “application\\”, “text\\”, “image\\”, “audio\\”, “video\\” I don’t know what I’m doing… Read More »

Regex to disallow plus sign and underscores

Questions: so I have a regex currently which looks like this: string username = Regex.Replace(competitor, @”(\s+|@|&|’|\(|\)|<|>|#)”, “”); What this does is removes @, &, ‘, (, ), <, or > and replaces them with “” (empty string) Now I’d like to add to this regex the following criteria as well: remove any part of string… Read More »

How can I match the given pattern using Regex in C#?

Questions: I have the following input: -key1:”val1″ -key2: “val2” -key3:(val3) -key4: “(val4)” -key5: val5 -key6: “val-6” -key-7: val7 -key-eight: “val 8” With only the following assumption about the pattern: Keys always start with a – followed by a value delimited by : How can I match and extract each key and it’s corresponding value? I… Read More »

JavaScript RegExr. Parsing html into text

Questions: I would like to convert a html code into text by using regexr. I am a beginner and I don’t really know how to do it with split() and replace()… For example: const = myArtcle { article: <p class=”some-style”>Some text with 094blabla.</p> <img src=”#” /><p class=”style”> etc…</p>. } I tried this: const textArticle =… Read More »

C# RegEx to match specific strings

Questions: I need to match (using regex) strings that can be like this: required: custodian_{number 1 – 9}_{fieldType either txt or ssn} optional: _{fieldLength 1-999} So for example: custodian_1_ssn_1 is valid custodian_1_ssn_1_255 is valid custodian or custodian_ or custodian_1 or custodian_1_ or custodian_1_ssn or custodian_1_ssn_ or custodian_1_ssn_1_ are not valid Currently I am working with… Read More »

Regex alternative for extracting numeric and non-numeric strings

Questions: Using the below expression, I’m able to get the expected output and extract numbers or string and split to a string array. Regex _re = new Regex(@”(?<=\D)(?=\d)|(?<=\d)(?=\D)”, RegexOptions.Compiled); _re.Split(“2323dfdf233fgfgfg ddfdf334”).Dump(); //string can be any alphanumeric start with How to achieve the same thing without using Regex? Do I need to parse each char and… Read More »