I have an array in PHP with URLs like below:
http://example.com/apps/1235554/
http://example.com/apps/apple/
http://example.com/apps/126734
http://example.com/images/a.jpg
http://example.com/images/b.jpg
http://example.com/apps/2331234/
http://example.com/apps/orange/
How can I separate out these urls and push them to another array using Regex:
http://example.com/apps/1235554/
http://example.com/apps/126734
http://example.com/apps/2331234/
Only url with apps/{number}/ and apps/{number} should be selected.
I have some strings that need a-strippin':
ÜT: 9.996636,76.294363
Tons of long strings of location codes. A literal regex in PHP won't match them, IE
$pattern = /ÜT:/;
echo preg_replace($pattern, "", $row['location']);
Won't match/strip anything. (To know it's working, /T:/ does strip the last bit of that string). What's the encoding error going on here?
Alternately, I would accept a concise way to take out just the numbers.
Just one simple, specific question:
I've got the string {var1}12345{var2}, and I want to get the variable names used.
if (preg_match("/{([a-zA-Z0-9]*)}/g", $url, $matches)) {
print_r($matches);
}
If I remove the global flag, it works, but I only get the first variable, as expected. Why isn't it working with a global flag? It works when I'm testing it with the Regex Tester
I notice the standard regex syntax for matching across multiple lines is to use /s, like so:
This is\nsome text
/This.*text/s
This works in Perl for instance but doesn't seem to be supported in Vim. Instead, I have to be much more specific:
/This[^\r\n]*[\r\n]*text/
I can't find any reason for why this should be, so I'm thinking I probably just missed the relevant bits in the vim help.
Can anyone confirm this behaviour one way or the other?
I have heard that MSBuild 4.0 has increased Regex parsing support. However, I am unable to find any detailed documentation/links/material on this. Can anyone give a brief description of the new features and/or possibly give pointers to more material?
Thanks in advance.
In my application which uses spring security I want to define two different areas both using their own spring security filter-chain. My question is: is it possible to define two regex expressions as follows:
every path starting with /foobar/*
every other path not starting with /foobar
The important part here is that the second path should also match if somewhere within it, but not in the beginning, it cotains the /foobar/ string.
Thanks
Hi StackOverflow,
I'm trying to group the following string into three groups.
0:0:Awesome:awesome
That being "0", "0" and "Awesome:awesome"
Using this regular expression:
^([0-9]+)\:([0-9]*)\:(.*)$
It works fine on online regex services: http://rubular.com/r/QePxt57EwU
But it seems like .NET doesn't agree.
I have this line ( it's a single line, SO makes it seem like 2 ):
/Od /D "WIN32" /D "_DEBUG" /FD /EHa /MDd /Fo"Debug" /Fd"Debug\vc80.pdb" /W3 /c /Zi /clr /TP .\main.cpp"
And I want to extract the .\main.cpp. I thought the following would do the trick:
if($string =~ /.*\s+(.*)$/i) {
print "matched ",$1,"\n";
}
because this same regex works in Ruby, and extracts the string I required. How can I get it working?
I have a string like
Pakistan, officially the <a href="Page.aspx?Link=Islamic Republic of Pakistan">Islamic Republic of Pakistan</a>
Now I am using
System.Text.RegularExpressions.Regex.Replace(inputText, "(\\bPakistan\\b)", "something");
to replace Pakistan outside the tags. But I don't want to replace Pakistan occurring within the <a></a> tags.
Hi,
I am dealing with developing and Application for European Client and they have their native character set.
Now I need to have regex which would allow foreign characters like eéèêë etc and am not sure of how this can be done.
Any Suggestions ?
I have a string which looks like this:
"[segment1][segment2][segment2]"
What I'd like is to be able to split the string into an array, so I'd end up with:
Array[0] = "segment1", Array[1] = "segment2", Array[2] = "segment3"
I've tried using the string split function, but it doesn't seem to do exactly what I want. I was wondering if anyone has some regex which might help me out?
Thanks in advance
I have a string that has some double quoted substring in it, the " character. In between the double quotes is the data i want.
How can i write a regex to extract "the first data i want" and "the second data i want" from this:
'some string with "the first data i want" and "the second data i want"'
I tried the following code.
<cfset mydata = 'some string with "the first data i want" and "the second data i want"'/>
<cfset arrData = ListToArray(mydata ,'"') />
How to replace from regex many empty/blank characters with none? ex:
<div class="someClass" id="someID">
...bunch of elements/content
<input type="button" name="myInput" id="inputID" title="myInput Title" />
...bunch of elements/content
</div>
when replaced :
<a class="myselector" rel="I need this value"></a><div class="someClass" id="someID">...bunch of elements/content<input type="button" name="myInput" id="inputID" title="myInput Title" />...bunch of elements/content</div>
I have a string:
[\n['-','some text what\rcontains\nnewlines'],\n\n
trying to parse:
Regex.Split(@"[\n['-','some text what contains newlines'],\n\n", @"\[\n\['(.*)','(.*)'],.*");
but the split return array seems to be null
i need to get part of text: "some text what contains newlines"
found this regex:
insert " " every 10 characters:
$text = preg_replace("|(.{10})|u", "\${1}"." ", $text);
can you, please, explain what \${1} means. Why using \ and what curly brackets means?
How to create regex pattern which is concatenate with variable, something like this:
var test ="52";
var re = new RegExp("/\b"+test+"\b/");
alert('51,52,53'.match(re));
Thanks
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)\))
Hi, Could someone help me with the following RegEx query: based on the following rules:
1) 1 letter followed by 4 letters or numbers, then
2) 5 letters or numbers, then
3) 3 letters or numbers followed by a number and one of the following signs: ! & @ ?
You will have to allow customers to input the fidelity card code as a 15-character string, or as 3 groups of 5 chars, separated by one space.
Specifically, I'm using the linux command:
find . -regextype posix-extended -regex '' ...
I just want to make sure the posix type I'm using is the type Perl uses, since that is by far the one I am most familiar with.
Is there a singular regular expression that can be used in, say, a text editor's search/replace dialog to reverse the order of the items in a list?
For instance, take this list:
First item
Second item
Third item
Select it in a text editor like EditPad, bring up the search and replace box, apply a regex (run as a loop or not) and turn it into:
Third item
Second item
First item
Can this be done?