regex

os.walk and some tests

Hello guys. I'm not sure if i understand properly how os.walk store its results. Im trying to do the following: I'm checking a root folder for subsequent folders. There are several hundreds of em, and they are nested in somewaht uniform way. I'm trying to check each subfolder, and if it ends with a four digit number, store it in a lis...

How do I validate an entry on an email using regex?

I am looking for a reg expression to check for entry XXXXX between store locator and Store number in an email. Store Locator: XXXXXX Store Number: ...

Regular expression capture groups in Oracle PL/SQL

I'm trying to turn free-form text into something more structured. I have a complex pattern that matches the great majority (well above the minimum acceptable limit) of the data available, and I'd like to use that to assist in structuring the data, rather than parsing the text character-by-character. The problem that I've just run into is...

Matching string and then characters until a specified string appears again

Hi I have the following string: <tr><td>2.</td></tr><tr><td colspan="25"><img src="/adad4.gif" alt="" align="middle"></td></tr><tr><td>3.</td></tr><tr><td colspan="25"><img src="/h5s6c.gif" alt="" align="middle"></td></tr><tr><td>4.</td></tr><tr><td>5.</td><td>2</td></tr> I want to remove alle occurrences of <tr><td colspan="25"><i...

Regex for replacing a single-quote with two single-quotes

I'm running into an issue that I think is being caused by needing to double-up on some single quotes inside a string. However, JS's string.replace uses RegEx, and I've never built a RegEx by hand. Can someone help me build a RegEx to find a single quote and replace it with two single quotes? ...

Regex convert string to valid number, no decimal, sign optional

Removing everything after and including the decimal, and everything non-numerical except the dash if its in is the first character. So far I have this: /[^0-9^-]|[^\.]+$/. Notice How I block dashes from being removed with ^-, because somehow I want to only remove the dashes that aren't the first character (not the sign). Any help? Thanks...

Preg match on php display code

Hi all im currently writing a "display php code" function (output can be seen at http://www.actwebdesigns.co.uk/web-design-mansfield/php-functions/display-code-function.php) Im having trouble with the color scheme which is done by regular expression. The 2 in particular are: strings: $line = preg_replace("#(\s|\()(\"[^\"]*\")(\,|\))#i...

Regular Expression problem in Java

Hi everyone, I am trying to create a regular expression for the replaceAll method in Java. The test string is abXYabcXYZ and the pattern is abc. I want to replace any symbol except the pattern with +. For example the string abXYabcXYZ and pattern [^(abc)] should return ++++abc+++, but in my case it returns ab++abc+++. public static Stri...

Remove all non-"word characters" from a String in Java, leaving accented characters?

Apparently Java's Regex flavor counts Umlauts and other special characters as non-"word characters" when I use Regex. "TESTÜTEST".replaceAll( "\\W", "" ) returns "TESTTEST" for me. What I want is for only all truly non-"word characters" to be removed. Any way to do this without having something along the lines of "[^...

How can I replace all hotmail.com addresses in a file with another email address, using Perl?

Hello all, I have multiple email id's in some config files in a directory; I'm running my scripts on a Solaris machine. I want to perform the following: Find all the email_id's in the config files in a directory: eg: [email protected] ; [email protected] ; [email protected] ; [email protected] Replace all existing id's with: wxyz@hotmail....

Regex to match links that arent already marked up

I'm trying to write a regex to automatically find urls, so that I can turn them into marked up a hrefs. The issue I'm having is dealing with urls that have already been marked up (The documents contain a mix of marked up and not marked up urls). So basically my problem comes down to this: I want to match any URL that isn't already enc...

C# extracting certain parts of a string.

Hi All I have a console application which is parsing HTML documents via the WebRequest method (http). The issue is really with extracting data from the html code that is returned. Below is a fragment of the html I am interested in: <span class="header">Number of People:</span> <span class="peopleCount">1001</span> <!-- this is the li...

How to do ANDing of conditions in a regular expression?

I want to match and modify part of a string if following conditions are true: I want to capture information regarding a project, like project duration, client, technologies used, etc.. So, I want to select string starting with word "project" or string may start with other words like "details of project" or "project details" or "project...

C# Regular Expression Help

Given the following strings 7;#User One 7;#User Two;#9;#User Two 7;#User Two;#9;#User Two;#123;#User Three I would like to build a regular expression that "breaks" these apart so that each string returns the following matches: ["7;#User One"] ["7;#User Two", "9;#User Two"] ["7;#User Two", "9;#User Two", "123;#User Three"] I tried a...

Find any literal with a Regular Expression

Hi folks, in my C# program, I have a regular expression textparser, that finds all occurrences of words that are surrounded by double squared brackets. For instance, [[anything]] would find the word anything. In a second step, I want to count how often the found word (in my example: anything) appears in the whole text. To do this, I tr...

script to add files to SVN with filters

My bash scripting is weak. I want to create a script that filters and add files to the svn. So far i have this ls | egrep -v "(\.tab\.|\.yy\.|\.o$|\.exe$|~$)" I tried to output it using exec but couldnt figure out how. Before that I checked if svn add uses regex. I am not sure if it does and i couldnt figure out how to reverse the ab...

Multi grep to 1 grep? Should i change it and how do i?

This is my final script find -regex "^\..*[^(~$|\.o$|\.exe)]" | grep -v "\.svn" | grep -v ".tab." | grep -v ".yy." | xargs svn add 2>/dev/null For testing i dont want to add it to svn so i use find -regex "^\..*[^(~$|\.o$|\.exe)]" | grep -v "\.svn" | grep -v ".tab." | grep -v ".yy." NOTE: I wanted to ignore files that started wit...

How do I access matched objects for replacement when using regular expression mode in PL/SQL Developer Find & Replace?

I have a query where I want to replace avg(j2) with avg(case when j2 <> 0 then j2 else 0 end) The above is a specific example but the pattern is the same with all the replacements. It's always a word followed by a number that needs to be replaced with the case statement that checks if the number is not 0. I tried the following for...

Generate pattern (and/or regex) automated from input

Heyho, I've got a big bunch of loglines (more or less without documentation) and need to parse the lines. The parsing itself won't be a big problem, but first I need to know how many different kinds of lines are inside the files. Besides the fact that I've got really different lines like short errors, up to bigger lines which are only di...

Regex for password requirements

I want to require the following: Is greater than seven characters. Contains at least two digits. Contains at least two special (non-alphanumeric) characters. ...and I came up with this to do it: (?=.{6,})(?=(.*\d){2,})(?=(.*\W){2,}) Now, I'd also like to make sure that no two sequential characters are the same. I'm having a heck ...