I need to dynamically build a Regex to catch the given keywords, like
string regex = "(some|predefined|words";
foreach (Product product in products)
regex += "|" + product.Name; // Need to encode product.Name because it can include special characters.
regex += ")";
Is there some kind of Regex.Encode that does this?
...
I'm looking for a REGEX to obtain a files extention.
Given examples like:
modocument.doc
modocument.docx
dasddsa.pdf
kdsksdklsadklasdklads.png
ads123.jpg
I need a REGEX that provides the 3-4 char extention, but isn't fooled by things like:
asdadsasdads.jpg.png
And only gets PNG as seen above. thxs
...
I have to write an argument parser, it is passed in as a string ala {a, b, c} delimiter is comma with a space after it, but it can be escaped with a pipe "|" before it. So I was thinking of writing a regex like /[^\|], / to split by, and then removing all the escape characters afterwards. But when using this it will split by the characte...
Is there a way to replace text with a regex inline, rather than taking the text from a variable and storing it in a variable?
I'm a perl beginner. I often find myself writing
my $foo = $bar;
$foo =~ s/regex/replacement/;
doStuff($foo)
where I'd really like to write
doStuff($bar->replace(s/regex/replacement/));
or the like, rather...
We're all familiar with naming conventions in R (if not: Venables & Smith - Introduction to R, Chapter 1.8). Regular expressions, on the other hand, remain terra incognita and the most hated part in my programming life so far ... Recently, I've officially started JavaScript recapitulation, and I'm trying to create precise RegExp to check...
Possible Duplicates:
How to get string from HTML with regex?
RegEx match open tags except XHTML self-contained tags
Hey there.
So i have some HTML code that i need to parse. I was wondering what the regex would look like to do this?
Basically the HTML is a large HTML document.
The structure looks something like this.
//Ra...
Possible Duplicate:
Programmatically access currency exchange rates
Hi .
I need a help again.
The deal is that i want to load a postbank.bg homepage, then just catch the HTML table where the exchange rate is , and to get the rates in an undertandable array which i can then process...
Any ideas , which is the easyest way ...
I need a PHP 5 regular expression for the following date/time format:
10 Jul 2010 15:00
(2 digits space 3 characters space 4 digits space 2 digits colon 2 digits)
Character case does not matter, and the only allowed input is a-z, 0-9, space, colon
Thanks in advance.
...
I discovered a bug that without a trailing number [0-9], my method will fail. Therefore I used a quick gsub to insert that number.
I'm working with this method:
def initialize(speciate)
y = speciate.gsub(/$/, '1')
x = y.scan(/[A-za-z]*\d+/)
@chem_species = x.map { |chem| chem.scan(/[A-Z][^A-Z]*/) }.flatten
end
Whe...
How would I convert this to C# from VB.net. I tried the online converters but I got errors when I put it in my project.
Dim regexinfo As String = String.Empty
Dim p = "\[news\](?<info>.*?)\[/news\]"
Dim Matches = Regex.Matches(response, p, RegexOptions.IgnoreCase Or RegexOptions.Singleline)
If Matches IsNot Nothing AndAlso Matches.Count...
Hi everyone,
I am working on a simple tool to check Java coding guidelines on a project.
One of those guidelines is to verify that there is no variables declared like "private static ...", only "private statitc final ..." is allowed.
I am wondering how I can get this result. I wrote this one :
pattern = "private\\s*static\\s*(?!final)...
I have two example filename strings:
jquery.ui.min.js
jquery.ui.min.css
What regex can I use to only match the LAST dot? I don't need anything else, just the final dot.
A little more on what I'm doing. I'm using PHP's preg_split() function to split the filename into an array. The function deletes any matches and gives you an array...
any way would be fine. Perl, python, ruby...
...
Hey guys,
I don't consider myself a PHP "noob", but regular expressions are still new to me.
I'm doing a CURL where I receive a list of comments. Every comment has this HTML structure:
<div class="comment-text">the comment</div>
What I want is simple: I want to get, from a preg_match_all, the comments that have the word "cool" in th...
hello..i need your help.
i have an array, it have same data:
data range
115X0101-115X0200
115X0101-115X0200
115X0101-115X0200
the 115x mean production code..this unimportant.
we just concern at four digits behind it that we can counting.
1. i want script read or search "0101" and "0200" from 115X0101-115X0200
2. i have tried u...
I have a file which looks like below.
1 1 0 # 1
6 1 0 # 2
8 1 0 # 3
10 1 0 # 4
12 1 0 # 6
How can I add .0 to all numbers, except the numbers behind the #. I think this should not be too difficult to do with a regular expression, but my regex knowledge is too rusty..
...
Hello Everyone, I'd like to develop an iPhone application that get's it's data from a web pages using regex applied on that web page. I was wondering if that's possible by the SDK.
Thanks
...
I have the following Regular Expression which matches an email address format:
^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$
This is used for validation with a form using javascript. However, this is an optional field. Therefore how can I change this regex to match an email address format, or an empty string?
From my limited regex knowledge, I t...
So I worked with Django for a bit and understand regex rudimentary.
I know if there is request it "maps"(not sure what that means) the urls to a certain definition in the view.
That is clear and understandable for one page.
But what if I want to design a urlpattern for multiple pages and/or the whole website.
I dont understand that...
I've inherited a codebase littered with DateTime objects created like this:
DateTime d = Convert.ToDateTime("2008-02-05");
which are failing when tests are ran on NY servers due to the culture of the string. I wish to convert them to the more sensible format:
DateTime d = new DateTime(2008,02,05);
I've written a VS macro that conve...