regex

regexp in java problem

Hello! I found some problem while testing my NLP system. I have a java regex "(.*\\.\\s*)*Dendryt.*" and for string "v Table of Contents List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " it just dont stop computing. Its clear that this regex complexity is very high, I will try to refactor it. H...

Regex with all optional parts but at least one required

I need to write a regex that matches strings like "abc", "ab", "ac", "bc", "a", "b", "c". Order is important and it shouldn't match multiple appearances of the same part. a?b?c? almost does the trick. Except it matches empty strings too. Is there any way to prevent it from matching empty strings or maybe a different way to write a regex...

regular expression search in python

Hello all, I am trying to parse some data and just started reading up on regular Expressions so I am pretty new to it. This is the code I have so far String = "MEASUREMENT 3835 303 Oxygen: 235.78 Saturation: 90.51 Temperature: 24.41 DPhase: 33.07 BPhase: 29.56 RPhase: 0.00 BAmp: 368.57 BPot: ...

Multiple Regex on String

How can I apply multiple regexs to a single string? For instance, a user inputs the following into a text area: red bird blue cat black dog and I want to replace each carriage return with a comma and each space with an underscore so the final string reads as red_bird,blue_cat,black_dog. I've tried variations in syntax along the line...

Regular Expression to return the contents of a HTML tag received as a string of text

I have a string in my code that I receive that contains some html tags. It is not part of the HTML page being displayed so I cannot grab the html tag contents using the DOM (i.e. document.getElementById('tag id').firstChild.data); So, for example within the string of text would appear a tag like this: <span id='myQty'>12</span> My ...

regex pattern matching for http

hi...i want to extract url from href of a webpage...for that i m using the regex pattern as "(?(http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)" to extract the href from html i used this pattern @"href=\""(?[^\""#]?(?=[\""#]))(?(?#{2}[^#]?#{2})*)(?#[^""]+)?""" but the problem is...it do not extract urls from the href but urls like "ww...

How can I identify the "tokens" (wrong word) of a regular expression

I'm working on a fairly specialized search engine implementation in Perl, it searches (by regex) documents for specifically delimited (a subset of :punct:) strings from a text file. I'm doing the usual search engine indexing tricks, but there's a problem. Some of the search regex patterns include, by necessity, delimiters used in the fi...

How do I extract info from a block of URLs in php?

I have a list of urls, which can come in any format. One per line, separated by commas, have random text in between them, etc. the URLs are all from 2 different sites, and have a similar structure For this example, lets say it looks like this Random Text - http://www.domain2.com/variable-value Random Text 2 - http://www.domain1.com/var...

Simple Search and Replace use of Regular Expression

So, I am adapting some code I found online to suit my needs. However, my set_pixel function has two more parameters. Since there are lots of calls to this function even doing a quick paste over would be very tedious. So, I thought this would be a good time for me to learn some simple regular expressions. So, I have calls of this type: ...

Regular expression literal

As I'm RegEx dyslexic.. what RegEx can you use to find each of the following strings - with the exception of "LoginException"? NullPointerException LoginException BooException Abc123Exception Edit: To be clear, I'm looking for these strings in a text/log file. ...

Regular expression works normally, but fails when placed in an XML schema

I have a simple doc.xml file which contains a single root element with a Timestamp attribute: <?xml version="1.0" encoding="utf-8"?> <root Timestamp="04-21-2010 16:00:19.000" /> I'd like to validate this document against a my simple schema.xsd to make sure that the Timestamp is in the correct format: <?xml version="1.0" encoding="utf...

Tab Delimited to Comma Separated file in UNIX - One liner?

I have a tab delimited file (MySQL Out file). I want to convert it into CSV file. I got everything working except for replacing NULLs to nothing or spaces. What I have is : sed -e 's/^/"/; s/$/"/; s/\t/","/g;' < file.csv > file1.csv How to also replace NULLs in the same line. The following doesn't work. sed -e 's/NULL//; s/^/"/; s/$...

Why isn't there a regular expression standard?

I know there is the perl regex that is sort of a minor de facto standard, but why hasn't anyone come up with a universal set of standard symbols, syntax and behaviors? ...

Find and Replace RegEx question

I am starting to get a grip on RegEx thanks to all the great help here on SO with my other questions. But I am still suck on this one: My code is: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); I am reading in a text file and I want to search for thi...

multiline sed using backreferences...

Hi, I'm converting patch scripts using a commandline script - within these scripts there's the combination two lines like: --- /dev/null +++ filename.txt which needs to be converted to: --- filename.txt +++ filename.txt Initially I tried: less file.diff | sed -e "s/---\/dev\null\n+++ \(.*\)/--- \1\n+++ \1/" But I had to find ou...

Regular expression- add target="blank" to all <a> tag links in my content

Can some one help me create a regular expression in C#.net to add target="_blank" to all tag links in my content? If the link already has a target set then replace it with "_blank". The purpose is to open all links in my content in a new window. Appreciate your help -dotnet rocks ...

Find and Replace RegEx with wildcard search and addition of value

The below code is from my other questions that I have asked here on SO. Everyone has been so helpful and I almost have a grasp with regards to RegEx but I ran into another hurdle. This is what I basically need to do in a nutshell. I need to take this line that is in a text file that I load into my content variable: X17.8Y-1.Z0.1G0H...

Regex expression in plain english

I'm working on a new Java project and therefore im reading the already existing code. On a very important part of the code if found the following regex expression and i can't really tell what they are doing. Anybody can explain in plain english what they do?? 1) [^,]*|.+(,).+ 2) (\()?\d+(?(1)\)) ...

javascript string exec strange behavior

have funciton in my object which is called regularly. parse : function(html) { var regexp = /...some pattern.../ var match = regexp.exec(html); while (match != null) { ... match = regexp.exec(html); } ... var r = /...pattern.../g; var m = r.exec(html); } with unchanged html the m returns...

String Manipulation with Regex.

I will have a different type of string(string will not have fixed format,they will be different every time) from them I want to remove some specific substring.Like the string can be FUTIDX 26FEB2009 NIFTY 0 FUTSTK ONGC 27 Mar 2008 FUTIDX MINIFTY 30 Jul 2009 FUTIDX NIFTY 27 Aug 2009 NIFTY FUT XP: 29/05/2008 I want to remove the string ...