regex

Replace text using regular expressions in MS Word - C#

Hi all, I have a Word document that I want to open and replace all instances of a social security number with the word, "test". I already have the code to open the document. Here's the code that would do the replacement. However, I'm having trouble with using regular expressions at this point: _wordApp.Selection.Find.Text = ; within m...

detect url's in text with Javscript/Prototype.js

Does anyone have suggestions for detecting url's in a set of elements and converting them to links? $$('#pad dl dd').each(function(s){ //detect urls and convert to a elements. }); ...

Windows text editor that shows/hides lines based on RegEx or Grep syntax?

Hi, all. One of my application components produces some extremely hairy log files. They require a lot of poking and prodding before they produce useful information. I'm on the hunt for a text editor for windows that will let me enter text in either RegEx or Grep-style syntax, and automatically show/hide the relevant lines. Does anyon...

Python regex question

Hi I am wondering what would be a pythonic solution for this question. http://stackoverflow.com/questions/1483757/in-aa67bc54c9-is-there-any-way-to-print-aa-67-times-bc-54-times-and-so-on ...

Why is this grep command not coming back with anything? (Bash)

I have a text file 'samp' that I want to grep ONLY lines that start and end with uppercase vowels. Using "grep ^[AEIOU] samp" works. Using "grep [AEIOU]$ samp" works as well. But when trying to combine them to "grep ^[AEIOU]$ samp" it returns nothing. 3 things: Yes, I have lines that start and end with uppercase vowels in samp. ...

PHP regular expression to match two needles

I'm looking to extract 2 elements from a string into an array. The string is a weather feed: Thursday at 08:00 BST: white cloud. 10°C (50°F) I want the "white cloud" and "10°C" parts. So I need to match between "BST:" and "." as well as between " " and "°C". I'm struggling with the regular expression(s) I need and would really appre...

Wildcards to regex in VS find & replace

I need to convert expressions of the form: return *; into: return filter(*); It seems simple enough to express it with wildcards, however, in visual studio's search & replace dailog, there's no way to associate the first asterisk with the second one. I suppose a regex can do this quite easily, however I know very little about regex...

Format XMl Document by adding "/" at the end of tag

So, i have some not well-formated xml document, some empty tags() don't have "/" at the end, example: <loader local="test.bat" dir="/usr/home"> And how can i elegant(using regex:)) add for each "loader" tag "/" at the of this tag(using Java); must be: <loader local="test.jpg" dir="/usr/home"/> ...

Creating a valid string from a regular expression

Hello, In the application I am currently working on, I have an option to create automatic backups of a certain file on the hard disk. What I would like to do is offer the user the possibility to configure the name of the file and its extension. For example, the backup filename could be something like : "backup_month_year_username.bak"...

Ajax Control Toolkit Editor Control - avoiding XSS attacks

I noticed in this article that Microsoft does not recommend using the Editor control from the Ajax Control Toolkit in public sites because of the danger of cross-site scripting attacks. I tried it out, and even if you specifically set NoScript="true" it's possible to add script, and therefore, introduce XSS attack vulnerabilities. In m...

What regex would match a nested table with identifiable text in the table cell?

What regex would match a nested table with identifiable text in the table cell? I've tried but failed to come up with a regular expression to extract the specific table I want with out grabbing the beginning and end of both tables in the example. Here is something to get started: "<table>.*?</table>" <table> <tr> <td> <ta...

Using Scanner in Java how can I hasNext(aString) where the string is not regex pattern?

Hi, I am trying to do as my question states, sooo I have the following code which would find the match. String test = scan.next(); if (test.equals("$let")) return 1; However, I would prefer to use hasNext as to not consume a token; however, when i do the following it fails. if (scan.hasNext("$let")) return 1; I realize the whe...

match an alternative url - regular expresion django urls

Hi, I want march a django-URL with just 2 alternatives /module/in/ or /module/out/ Actually Im using url(r'^(?P<status>\w+[in|out])/$', 'by_status', name='module_by-status'), But matches with other patterns like /module/i/, /module/n/, /module/ou/; etc. Any hint is apreciated :) ...

How do I use IIS7 URL rewriting to hide virtual directories?

I have a server with IIS7 that I am using to host several different sites for testing. Due to an overabundance of bureaucracy, I am unable to use host headers (I can't get new entries on our internal DNS server and users can not change their local hosts file). I have set up the default site in IIS to have nothing but virtual directorie...

Help me with a simple regular expression

Hello, I want to find a sequence of "select from where " in a string. For example, "select * from T WHERE t.c1 =1" should be matched. Here is the regular expression pattern I wrote: "SELECT\s\.*FROM\s\.*WHERE\s\.*"; But it doesn't work. What is wrong with it? Thanks in advance. ...

Haskell compilation problem

Hi. I have a problem compiling Haskell programs, that import the Text.Regex.Posix module. I have tried to isolate the problem in a small test program: module Main () where import Text.Regex.Posix ((=~)) main = return () Running the interpreter works fine: /regex-test$ runghc Main.hs /regex-test$ However, compiling this program wi...

Convert Single Line Comments To Block Comments

I need to convert single line comments (//...) to block comments (/*...*/). I have nearly accomplished this in the following code; however, I need the function to skip any single line comment is already in a block comment. Currently it matches any single line comment, even when the single line comment is in a block comment. That can't ha...

search with grep for words beginning and ending with

How to grep something which begins and end with a character ABC-0 ABC-1 ABC-10 ABC-20 I wanto to grep -v for ABC-0 and ABC-1 ...

Generate an abbreviation from a string in JavaScript using regular expressions?

I want to generate an abbreviation string like 'CMS' from the string 'Content Management Systems', preferably with a regex. Is this possible using JavaScript regex or should I have to go the split-iterate-collect? ...

how to extract all text from HTML file using PHP?

Hello how to extract all text from HTML file I want to extract all text, in the alt attributes, < p > tags, etc.. however I don't want to extract the text between style and script tags Thanks right now I have the following code <?PHP $string = trim(clean(strtolower(strip_tags($html_content)))); $arr = explode(" ", $str...