regex

Validating XML using XSD with regex pattern

Hello, I am parsing a XML file against a XSD containing some regex patterns used for checking input data, but only this regex generates an error, even if it passes into the Eclipse XSD plugin: InvalidRegex: Pattern value '(((com|org)\.)+(\b[a-z]+[.]{1}\b)+)?[A-Z]{1}[A-Za-z]+' is not a valid regular expression. The reported e...

parsing/matching string occurrence in C

I have the following string: const char *str = "\"This is just some random text\" 130 28194 \"Some other string\" \"String 3\"" I would like to get the the integer 28194 of course the integer varies, so I can't do strstr("20194"). So I was wondering what would be a good way to get that part of the string? I was thinking to use #in...

How to write a regular expression for excluding some special characters from string?

I want to exclude the following characters from my string: \-- ' < > Please tell me how to write a regular expression for this. ...

Regex to match card code input

How can I write a regex to match strings following these rules? 1 letter followed by 4 letters or numbers, then 5 letters or numbers, then 3 letters or numbers followed by a number and one of the following signs: ! & @ ? I need to allow input as a 15-character string or as 3 groups of 5 chars separated by one space. I'm implementing...

Matching First Alphanumeric Character skipping (The |An? )

I have a list of artists, albums and tracks that I want to sort using the first letter of their respective name. The issue arrives when I want to ignore "The ", "A ", "An " and other various non-alphanumeric characters (Talking to you "Weird Al" Yankovic and [dialog]). Django has a nice start '^(An?|The) +' but I want to ignore those a...

Return result of block passed to #scan during regex

I've searched and not been able to find the right way of doing what I'm trying to. I read a file line by line and want to create a new object from a regex on each line. I'm not using an XML parser because the data is not well formed and listed below is all I need to get from each line. I can't seem to get scan to return the result of th...

Easiest way to replace a substring in javascript

Whats the easiest way in javascript to replace ABC, DEF, GHI with XYZ in the following strings http://z.site.com/z/ABC/z/z.html http://z.site.com/z/DEF/z/z.html http://z.site.com/z/GHI/z/z.html ...

What is the php syntax for a REGEXP that changes "Last, First" into "Last..First"?

I need to create a php search function for names and need to change LastName, FirstName into LastName..FirstName to search the database. I don't know if this helps, but the string will originally be in the form a variable ($Client). I need the syntax for the three statements that find the string, matches, and makes the changes. ...

Regular Expression With Mask

I have a regular expression for phone numbers as follows: ^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$ I have a mask on the phone number textbox in the following format: (___)___-____ How can I modify the regular expression so that it accommodates the mask? ...

cant get regex to work as i want

With this function: function bbcode_parse($str) { $str = htmlentities($str); $find = array( '/\\*\*(.[^*]*)\*\*/is', ); $replace = array( '<b>' ); $str = preg_replace($find, $replace, $str); return $str; } And with text "My name is **bob**" I get in source code Hi my name is <b> Been trying to get this to work for a...

Parsing srt subtitles

Hi, I want to parse srt subtitles: 1 00:00:12,815 --> 00:00:14,509 Chlapi, jak to jde s těma pracovníma světlama?. 2 00:00:14,815 --> 00:00:16,498 Trochu je zesilujeme. 3 00:00:16,934 --> 00:00:17,814 Jo, sleduj. Every item into structure. With this regexs: A: RE_ITEM = re.compile(r'(?P<ind...

regex limit length of characters?

Is there a way to limit a regex to 100 characters WITH regex? \[size=(.*?)\](.*?)\[\/size] So [size=500]Look at me![/size] wouldnt work. I want to limit the numbers, only allow numbers between 1 and 100 ...

RegEx (php) - unite lines in multiline replacement

I need change background of all text that have two spaces from the start of the line. text shold be converted to "<div class='special'>text</div>" That is easy: $text = preg_replace("|^ (.+)|um", "<div class='special'>$1</div>", $text); But line1 line2 Is converted to <div class='special'>line1</div> <div class='spe...

Beginner questions on Java Regular Expression

Hello everyone. I began studying Java Regular Expression recently and I found some really intersting task.For example,I now need to dig out "Product Name","Product Description" and "Sellers for this product" out of the following HTML code.(I am sorry for the big chunck of code,but it is very straightforward) <td class="sr-check"> <input...

how to replace quotation marks with \"

hello. im trying to echo mediaplayer embed code with IF statement. is there any way to replace all quotation marks (") with (\")'s ? thank you.. ...

RegEx for a price in £

i have: \£\d+\.\d\d should find: £6.95 £16.95 etc + is one or more \. is the dot \d is for a digit am i wrong? :( JavaScript for Greasemonkey // ==UserScript== // @name CurConvertor // @namespace CurConvertor // @description noam smadja // @include http://www.zavvi.com/* // ==/UserScript== textNodes = do...

Better way to write this regex to match multi-ordered property list?

I've been whacking on this regex for a while, trying to build something that can pick out multiple ordered property values (DTSTART, DTEND, SUMMARY) from an .ics file. I have other options (like reading one line at a time and scanning), but wanted to build a single regex that can handle the whole thing. SAMPLE PERL # There has got to ...

Replacing Part of Text Using Sed

I have the following text file Eif2ak1.aSep07 Eif2ak1.aSep07 LOC100042862.aSep07-unspliced NADH5_C.0.aSep07-unspliced LOC100042862.aSep07-unspliced NADH5_C.0.aSep07-unspliced What I want to do is to remove all the text starting from period (.) to the end. But why this command doesn't do it? sed 's/\.*//g' myfile.txt What's the righ...

Replacing multiple bar (special char) with tab using sed

I have a string like this BRADI5G20430|BRADI5G20430.1||1 How can I replace the bar (single and multiple) with tab ("\t")? I tried this but dont' work sed 's/\|+/\t/g' I also want to include this line in bash script. ...

Best way to split a string by word (SQL Batch separator)

I have a class I use to "split" a string of SQL commands by a batch separator - e.g. "GO" - into a list of SQL commands that are run in turn etc. ... private static IEnumerable<string> SplitByBatchIndecator(string script, string batchIndicator) { string pattern = string.Concat("^\\s*", batchIndicator, "\\s*$"); RegexOptions opti...