I have to port some C# code to Java and I am having some trouble converting a string splitting command.
While the actual regex is still correct, when splitting in C# the regex tokens are part of the resulting string[], but in Java the regex tokens are removed.
What is the easiest way to keep the split-on tokens?
Here is an example of ...
I have config.properties file containing properties in Java Properties format.
I need to replace the value of a property with a known name with a new value. The comments and formatting of the file should be preserved.
My current approach is to use RegEx to match the property name and then replace its value. However, Java Properties supp...
Hi guys, I'm finally parsing through wikipedias wiki text. I have the following type of text here:
{{Airport-list|the Solomon Islands}}
* '''AGAF''' (AFT) – [[Afutara Airport]] – [[Afutara]]
* '''AGAR''' (RNA) – [[Ulawa Airport]] – [[Arona]], [[Ulawa Island]]
* '''AGAT''' (ATD) – [[Uru Harbour]] – [[...
I need to "grab" an attribute of a custom HTML tag. I know this sort of question has been asked many times before, but regex really messes with my head, and I can't seem to get it working.
A sample of XML that I need to work with is
<!-- <editable name="nameValue"> --> - content goes here - <!-- </editable> -->
I want to be able to g...
Hey guys,
I'm trying to come up with a regex that helps me validate a Blood Group field - which should accept only A[+-], B[+-], AB[+-] and O[+-].
Here's the regex I came up with (and tested using Regex Tester):
[A|B|AB|O][\+|\-]
Now this pattern successfully matches A,B,O[+-] but fails against AB[+-].
Can anyone please suggest...
I have this regex in PHP:
preg_match('/\[summary\](.+)\[\/summary\]/i', $data['text'], $match);
It works fine when the text between the summary tags is on one line. However, when it contains newlines, it doesn't match.
I've tried to find a correct modifier here: http://nl2.php.net/manual/en/reference.pcre.pattern.modifiers.php
But th...
I am validating a Phone Number textbox. I would like to first strip the unneccessary characters from the value entered then validate that the number of characters is not more or less than 11. I know how I would do this in C# code. Unfortunately I now need to do this in an XML document. Validating the length of the corrected data is not a...
I want to replace whitespace with underscore in a string to create nice URLs. So that for example:
"This should be connected" becomes "This_should_be_connected"
I am using Python with Django. Can this be solved using regular expressions?
...
Whenever I do a commit cycle in svn, I examine the diff when writing my comments. I thought it would be really nice to show the actual function that I made the modifications in when showing the diff.
I checked out this page, which mentioned that the -p option will show the C function that the change is in. When I tried using the -p ...
I need to match an infinite number of figures in a web page.
I need to be able to match all of the following formats:
100 $
99$
$99
$ 8
$.99
$ .8
$ 99.8
.99$
.99 $
9.2 $
1.2$
And the equivalent using commas:
444,333
22,333
1,222
11,111,111
333,333,333,333.01132
Or spaces:
444 333
22 333
1 222
11 111 111
333 333 333 333.01132
Th...
Hi,
Does anyone know how to find all characters before the last underscore in a filename.
IABU_Real_Egypt_AUS09_012.indd
The result I need is IABU_Real_Egypt_AUS09
Thanks in advance
...
What's the best way to use regular expressions with options (flags) in Haskell
I use
Text.Regex.PCRE
The documentation lists a few interesting options like compCaseless, compUTF8, ...
But I don't know how to use them with (=~)
...
I have written regexes for recognizing float and int but they don't seem to work (code below).
{
string sumstring = "12.098";
Regex flt = new Regex(@" ^[0-9]*(\.[0-9]*)");
Regex ent = new Regex("^[0-9]+");
if (d_type.IsMatch(sumstring))
{
Console.WriteLine(sumstring + " " + "dtype");
}
Match m = en...
I have this array.prototype on my page and it seems to be sucking up a lot of processing time:
Array.prototype.findInArray = function(searchStr) {
var returnArray = false;
for (i=0; i<this.length; i++) {
if (typeof(searchStr) == 'function') {
if (searchStr.test(this[i])) {
if (!returnArray) { r...
I have a string and I need to see if it contains the following "_archived".
I was using the following:
preg_match('(.*)_archived$',$string);
but get:
Warning: preg_match() [function.preg-match]: Unknown modifier '_' in /home/storrec/classes/class.main.php on line 70
I am new to Regular Expressions so this is probably very easy.
O...
What would be a good way to get rid of all chars except, letters, numbers, double quotes and hyphens. This is what I got so far.
$test = preg_replace('#[^a-zA-Z0-9"-]#',' ',$string);
Any suggestions?
Thanks
...
This doesn't work:
string a = "=";
Regex oper = new Regex(@"[=-*/+]");
if (oper.IsMatch(a))
Console.WriteLine("operator");
else
Console.WriteLine("yt");
I don't know whether I'm defining regex incorrectly or I'm missing something. Suggestions?
...
Firstly, I'm in C# here so that's the flavor of RegEx I'm dealing with. And here are thing things I need to be able to match:
[(1)]
or
[(34) Some Text - Some Other Text]
So basically I need to know if what is between the parentheses is numeric and ignore everything between the close parenthesis and close square bracket. Any RegEx...
I have the following string:
This *is* a *test*!
I want to bold the words surrounded by the * characters (so "is" and "test" in the example).
I have the following JavaScript code:
var data = "This *is* a *test*!";
return data.replace(/\*(.*)\*/g, <b>$1</b>);
When the string is returned, I get the following:
This <b>is* a *test</b...
I have a string value that its length is 5000 + characters long , i want to split this into 76 characters long with a new line at the end of each 76 characters. how woudld i do this in c#?
...