I'm stuck on a RegEx problem that's seemingly very simple and yet I can't get it working.
Suppose I have input like this:
Some text %interestingbit% lots of random text lots and lots more %anotherinterestingbit%
Some text %interestingbit% lots of random text OPTIONAL_THING lots and lots more %anotherinterestingbit%
Some text %interesti...
I'm trying to parse an array of JSON objects into an array of strings in C#. I can extract the array from the JSON object, but I can't split the array string into an array of individual objects.
What I have is this test string:
string json = "{items:[{id:0,name:\"Lorem Ipsum\"},{id:1,name"
+ ":\"Lorem Ipsum\"},{id:2,name:\...
I would like to be able to switch this...
My sample [a id="keyword" href="someURLkeyword"] test keyword test[/a] link this keyword here.
To...
My sample [a id="keyword" href="someURLkeyword"] test keyword test[/a] link this [a href="url"]keyword[/a] here.
I can't simply replace all instances of "keyword" because some are used in or w...
I would like to redirect the following as an example:
A.olddomain.com.au/blah.html > A.newdomain.com/blah.html
B.olddomain.com.au/blah.html > B.newdomain.com/blah.html
Essentially, I have a variable number of subdomains and I only want to change the domain name itself on the redirect.
Any clues or suggestions to try out?
Thanks....
Hi Guys,
I have a textbox for 'Area '.I need a regularexpression to validate textbox such that it should allow decimals to enter but no characters.Anyone can help me
...
Hi, unfortunately despite having tried to learn regex at least one time a year for as many years as I can remember, I always forget as I use them so infrequently.This year my new years resolution is to not try and learn regex again - So this year to save me from tears I'll give it to stackoverflow. (Last Christmas remix).
So basically I...
In C# should you have code like:
public static string importantRegex = "magic!";
public void F1(){
//code
if(Regex.IsMatch(importantRegex)){
//codez in here.
}
//more code
}
public void main(){
F1();
/*
some stuff happens......
*/
F1();
}
or should you persist an instance of a Regex containing the important pattern?...
I need to find all the regex matches from a list of strings. For example, I need to be able to take the string "This foo is a foobar" and match any instances of either "foo" or "bar". What would the correct pattern be for this? Also, what input sanitation would I need to do to prevent the inputted text from breaking the pattern?
...
What's the best way to profile Perl regexes to determine how expensive they are?
...
After reading this article http://www.codinghorror.com/blog/archives/000228.html I understand the benefits of compiled regular expressions a little better, however in what personal scenarios would you consider mandates the use of a compiled Reg Ex?
For instance, I am using a regex in a loop and the regular expression string utilises dif...
It is my understanding that the java.regex package does not have support for named groups (http://www.regular-expressions.info/named.html) so can anyone point me towards a third-party library that does?
I've looked at jregex but its last release was in 2002 and it didn't work for me (admittedly I only tried briefly) under java5.
...
This relates to a previous question: How can I read Perl data structures from Python?. It could be a bug in the version of the YAML parser that I'm working with (0.66), but when I run:
perl -MYAML -le 'do shift; print YAML::Dump( $CPAN::Config )' simple.pl
On the following simple.pl:
%config = (
'color' => 'red',
'numbers' =>...
In Javascript I have defined a regular expression and now a user is typing in a string. I want to tell him if his string still could match the RegExp if he continues typing or if he's already on the wrong way. For instance:
var re = /a*b/;
"a".isPrefixOf( re ); // true
"x".isPrefixOf( re ); // false
How could an implementation of isP...
Is there a way to test if a regular expression "contains" another regular expression?
For example:
RegEX1 = "a.*b";
RegEx2 = "a1.*b";
RegEX1 "contains" RegEX2.
As far as I know - this can't be done, am I wrong?
OK, joel.neely has shown that it can be done (haven't read it yet...) academically.
Can it be done in a programming language...
Duplicate of http://stackoverflow.com/questions/362793/regexp-that-matches-valid-regexps
How do you produce a regex that matches only valid regex?
For instance: "[hc]at" would be valid (matching "hat" and "cat"), but "[hcat" would be invalid, as it is missing ].
...
Hi,
I have this string: " Mimi loves Toto and Tata hate Mimi so Toto killed Tata"
I want to write a code that print only the words that begin with capital letters, avoiding repetition
the Output should be like
Mimi
Toto
Tata
I tried to do so but I'm sure its wrong even though no errors are showing.
The code i wrote :
static void...
class Program
{
static void Main(string[] args)
{
string s = "the U.S.A love UK";
Console.WriteLine(replace(s));
}
public static string replace(string s)
{
s = Regex.Replace(s, @"^U.S.A", " United state Of America");
s = Regex.Replace(s, @"^Uk", ...
I am working with legacy systems at the moment, and a lot of work involves breaking up delimited strings and testing against certain rules.
With this string, how could I return "Active" in a back reference and search terms, stopping when it hits the first caret (^)?:
Active^20080505^900^LT^100
Can it be done with an inclusion in the ...
I.e.:
echo H#97llo | MagicPerlCommand
Stdout:
Hallo
were MagicPerlCommand is something like
perl -pnle "s/#(\d+)/chr(\1)/ge"
(but that doesn't work).
...
I have this sample text, which is retrieved from the class name on an html element:
rich-message err-test1 erroractive
rich-message err-test2 erroractive
rich-message erroractive err-test1
err-test2 rich-message erroractive
I am trying to match the "test1"/"test2" data in each of these examples. I am currently using the following rege...