regex

Java regex to match all html elements except one special case

I have a string with some markup which looks like this: The quick brown <a href="www.fox.org">fox</a> jumped over the lazy <a href="entry://id=6000009">dog</a> <img src="dog.png" />. I'm trying to strip away everything except the anchor elements with "entry://id=" inside. Thus the desired output from the above example would be: The qu...

How do I convert strings in code to uppercase in visual studio?

I'm trying to convert all character strings that match a particular regex in a file to uppercase, but I can't find the syntax to specify that within the 'Find and replace' window in visual studio. Is it possible to do this using the visual studio regex? ...

Regex newbie question on start and end of captures

I need some help with regular expressions. Please see the example below. I am capturing specific rid values that are contained between between this ","children":[ and ending with this }]}]} as shown below. My problem is that the block shown below repeats itself several times and I want all rids between the start of ","childre...

Matching tabbed in blocks of text using regex

How can I match a block of text that is indented using tabs? Say I have the following text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. # This is a text block @some = 'ruby' @then = 'some more' Aliquam malesuada scelerisque orci, sed venenatis sem eleifend ac. Vestibulum vehicula sagittis commodo. Praesent ...

.NET Regex for whitelisted characters

Consider an algorithm that needs to determine if a string contains any characters outside the whitelisted characters. The whitelist looks like this: '-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÖÜáíóúñÑÀÁÂÃÈÊËÌÍÎÏÐÒÓÔÕØÙÚÛÝßãðõøýþÿ Note: spaces and apostrophes are needed to be included in th...

SCORM 2004 Time Format - Regular Expression?

I am building a SCORM 2004 javascript API for an LMS, and one of the SCORM 2004 requirements is that timeintervals passed into it must follow the following format. Does anyone know what the regular expression of this would be? I am trying to wrap my mind around it, but to no avail. Note: P must always be the first character. P[yY]...

How can I check for the correct location of commas in a number entered by a user?

I'm looking for a good way to check a number that a user has entered for correct position of an optional comma(s). For example 1,000,000.00 = correct 1000000 = correct 1,00,000.00 = incorrect ,100,000 = incorrect So it looks like i need to check to see that there is at least one number to the left and 3 numbers to the right of the com...

String split question using "*"

Let's say have a string... String myString = "my*big*string*needs*parsing"; All I want is to get an split the string into "my" , "big" , "string", etc. So I try myString.split("*"); returns java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0 * is a special character in regex so I try escaping.... my...

How to get a part of url between 4th and 5th slashes?

Hello! Please help! I'm on PHP. I have an url: 'http://example.com/articles/123a/view', how do I get '123a' only from this string with regular expression (preg_replace, probably). Can't figure it out. Thanks in advance. ...

How can I combine a positive and negative condition in a regex?

I fairly new to regular expressions and need some help. I need to filter some lines using regex in Perl. I am going to pass the regex to another function so it needs to be done in a single line. I want to select only lines that contain "too long"and that don't begin with "SKIPPING" Here are my test strings: SKIPPING this bond sinc...

Regex remove whitespace at begining

Simple question but I got a headache to solve this game. Example regex. [a-zA-Z0-9\s] [whitespace]Stack[whitespace]Overflow - not allow Stack[whitespace]Overflow - allow Stack[whitespace]Overflow[whitespace] - not allow Let me know Update regex from JG and it's working. function regex($str) { $check = preg_replace('/^[a-zA-Z0...

Split string into array by regular expression

I need to create an array by searching a string for occurrences of '[' followed by 0 or more characters followed by ']'. My test string: $string="[item 1] [2] [] [item3]"; All of the above must be matched. I think the regex to do so is \[*\] But how do I create an array out of the string? Do I use preg_match_all("\[*\]", $stri...

How to write a good regex to distinguish between Arabic and English characters in Oracle using the AR8MSWIN1256 encoding?

I've been scouring Google and can't seem to find an answer. I'm running Oracle 10g Enterprise with the following character-set: AR8MSWIN1256 The database holds English and Arabic values, and I need to differentiate between the two from time to time. I wrote this script, which matches on English words but not on Arabic words: create or ...

Regex for fixed width field

I need to match a fixed width field on a file layout with a regular expression. The field is numeric/integer, always have four characters and is included in the range of 0..1331. When the number is smaller than 1000, the string is filled with left zeros. So all these examples are valid: 0000 0001 0010 1000 1331 But the following must...

Apache mod-rewrite folder overwrite

Hello, I have Apache installed with the XAMPP package, and I'm working locally. I have a rule in a .htaccess file that overwrites everything, let's take this for example: RewriteRule ^(.*)$ index.php?x=$1 Note that I do NOT have any RewriteCond that makes this rule ignore existing file or folders. Now let's say I have a folder name...

MySQL. I stink at RegExs. Just need one to tell me if string starts with a numeral

I need a MySQL query w/ Regex to tell me if my string's first character is a number from 0 to 9. ...

Regex matching spaces, but not in "strings"

I am looking for a regular exression matching spaces only if thos spaces are not enclosed in double quotes ("). For example, in Mary had "a little lamb" it should match the first an the second space, but not the others. I want to split the string only at the spaces which are not in the double quotes, and not at the quotes. I am usin...

How to validate a string against legal characters in standard C?

I want to validate a string against legal characters using standard C. Is there a standard functionality? As far as I can see, GNU Lib C's regex lib is not available in VC++. What do you suggest for implementing such a simple task. I don't want to include PCRE library dependency. I'd prefer a simpler implementation. ...

Regular Expression Pattern (match URL)

hi, I need a regular expression that identify special links. I have an array with links, for example this one array[1] = "http://domain.com/dfdf" array[2] = "http://domain.com/dfgf" array[3] = "http://domain2.com/derf" I want to use a regular expression that extract links from this array under a specific domain (for example domain2) ...

Regular Expression "AND"

I'm doing some basic text matching from an input. I need the ability to perform a basic "AND". For "ANY" I split the input by spaces and join each word by the pipe ("|") character but I haven't found a way to tell the regular expression to match any of the words. switch (searchOption) { case "any": inputArray = input.split(" "); ...