I have an application which needs to find and then process files which follow a very specific naming convention as follows.
IABC_12345-0_YYYYMMDD_YYYYMMDD_HHMMSS.zip
I cant see any easy way of doing this using a search pattern so Im assuming Ill have to do something like this after I have generated a list of files using a simpler wild...
What would a regular expression be to find sets of 2 unescaped double quotes that are contained in columns set off by double quotes in a CSV file?
Not a match:
"asdf","asdf"
"", "asdf"
"asdf", ""
"adsf", "", "asdf"
Match:
"asdf""asdf", "asdf"
"asdf", """asdf"""
"asdf", """"
...
Here is the data source, lines stored in a txt file:
servers[i]=["name1", type1, location3];
servers[i]=["name2", type2, location3];
servers[i]=["name3", type1, location7];
Here is my code:
string servers = File.ReadAllText("servers.txt");
string pattern = "^servers[i]=[\"(?<name>.*)\", (.*), (?<location>.*)];$";
Regex r...
I'm trying to write a regular expression replace expression that will replace a fully-qualified generic type name with its C# equivalent. For example, the following text:
System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MyNamespace.MyClass, MyAssembly,...
How can I convert a string to a regular expression that matches itself in Perl?
I have a set of strings like these:
Enter your selection:
Enter Code (Navigate, Abandon, Copy, Exit, ?):
and I want to convert them to regular expressions sop I can match something else against them. In most cases the string is the same as the regular exp...
This is the sample
"abc","abcsds","adbc,ds","abc"
Output should be
abc
abcsds
adbc,ds
abc
...
In short, I need to match all URLs in a block of text that are for a certain domain and don't contain a specific querystring parameter and value (refer=twitter)
I have the following regex to match all URLs for the domain.
\b(https?://)?([a-z0-9-]+\.)*example\.com(/[^\s]*)?
I just can't get the last part to work
(?![&?]refer=twitter)...
Hello, i'm trying to replace a text which contains url's with the text with the tags and i'm trying to use something like this, but i just don't get why this is not working, maybe i'm too tired too see it. Here goes my test:
[Test]
public void Check() {
string expUrl = @"^(https?://)"
+ @"?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*...
Using the Twitter API, how would you retrieve all updates that are in all CAPS?
...
What does the underscore mean in the following regex?
[a-zA-Z0-9_]
The _ seems to make no difference so I don't understand the purpose of it.
...
$url = "example-com--folder";
$searchArray = array('/-/','/--/');
$replaceArray = array('.','/');
$url = preg_replace($searchArray, $replaceArray, $url);
The output I want is example.com/folder but all I get now is example.com..folder
I know this is because I don't have the proper regex pattern, but what would that pattern be?
...
I'm a little stumped on this one and I'm also not still on 1.8 so I don't have lookahead.
I have a bunch of strings which can look like:
"a/b/c/d/e/f 1/2/3"
which I want to turn into:
"a/b/c/d/e" "f" "1/2" "3"
So basically I want it to split by the last slash before the beginning of whitespace. I feel like I can do this normally b...
I've stumped myself trying to figure out how to remove carriage returns that occur between <p> tags. (Technically I need to replace them with spaces, not remove them.)
Here's an example. I've used a dollar sign $ as a carriage return marker.
<p>Ac nec <strong>suspendisse est, dapibus.</strong> Nulla taciti curabitur enim hendrerit.$
An...
I'm in need of a tricky regex and I don't know if it can be written.
I'm trying to clean up some horrid html output from Ms Word. Here's an exmaple of the dandy that it does on an ordered (or numbered) list.
<p>1.
Proin Facilisi Habitasse Hymenaeos Ligula Lito...
hey,
I have the following scenario:
I have 5 possible values on a page:
[value 1]
...
[value 5]
What I want to do is grab each value and brackets...
Example Content:
<p>velit, sed quia non numquam eius modi tempora incidunt ut labore et
dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam,
quis nostrum exercitatio...
Given a string with attribute/value pairs such as
attr1="some text" attr2 = "some other text" attr3= "some weird !@'#$\"=+ text"
the goal is to parse it and output an associative array, in this case:
array('attr1' => 'some text',
'attr2' => 'some other text',
'attr3' => 'some weird !@\'#$\"=+ text')
Note the inconsisten...
I've got the following code:
Regex.Replace(text, words.ToString(), "<dfn title=\"" + this.FindDefinition("$0") + "\">$0</dfn>", RegexOptions.IgnoreCase | RegexOptions.Compiled);
The problem I'm having is with the FindDefinition method. I would like to send in the originale word to make a lookup and return the definition text. Is this...
I am new to regular expressions.
I want to do multiline search. Here is the example of what I want to do:
Suppose I have following text:
*Project #1:
CVC – Customer Value Creation (Sep 2007 – till now)
Time Warner Cable is the world's leading media and entertainment company, Time Warner Cable (TWC) makes coaxial quiver.
Client ...
Hello again.
$string = preg_replace("#\[name=([a-zA-Z0-9 .-]+)*]#",'<td><a href="' . "$front_page/" . str_replace(' ', '-', "$1") . '">'."$1</a></td>",$string);
This part of script doesn't work:
str_replace(' ', '-', "$1")
I need to replace " " with "-",
i also try preg_replace inside main preg_replace, str_ireplace also
But this...
I have been looking for a regular expression with Google for an hour or so now and can't seem to work this one out :(
If I have a number, say:
2345
and I want to find any other number with the same digits but in a different order, like this:
2345
For example, I match
3245 or 5432 (same digits but different order)
How would I write...