Hi
I want to match strings like those below.
abc|q:1,f:2
cba|q:1,f:awd2,t:3awd,h:gr
I am using php and have tried both preg_match and preg_match_all with this expression.
/^([a-z]+)\|([a-z]+:[a-z0-9]+,?)+$/iU
This only returns the first part before the pipe, and one a:1. What am I doing wrong, why is it behaving this way and how c...
hello, I'm currently writing a script editing app in c# to edit game scripts. I want to be able to load a script file and get the name of an NPC object and the script contents. The script looks like this:
INSTANCE PC_Thief(NPC_DEFAULT)
{
//-------- primary data --------
name = "Diego";
Npctype = NPCTYPE_FRIEND;
gui...
I'm looping through thousands of strings with various regexes to check for simple errors. I would like to add a regex to check for the correct use of commas.
If a comma exists in one of my strings, then it MUST be followed by either whitespace or exactly three digits:
valid: ,\s
valid: ,\d\d\d
But if a comma is followed by any othe...
Hi,
I'm trying to create a route that will "cover" this kind of URLs:
www.test.com/parent1/parent2/parent3/item
www.test.com/parent1/parent2/parent3/parent4/item1
Number of those parents in unspecified, and it should only serve to give a better, more intuitive look to site URLs. Main parameter is that "item".
I suppose that...
I've been trying to design a Google AppEngine Python handler regex and haven't been too successful in getting it to work.
I'm trying to handle API calls similar to OpenStreetMap's.
My current regex looks like this:
/api/0.6/(.*?)/(.*?)\/?(.*?)
But when this comes in:
/api/0.6/changeset/723/close
It incorrectly groups 723/close and ...
I have a string in the file
"abc def ghi " klm "ghi ";
I want to escape all occurrences of " in the string , output of the result
"abc def ghi \" klm \"ghi";
...
I'm interested how can be implemented recursive regexp matching in Python (I've not found any examples :( ). For example how would one write expression which matches "bracket balanced" string like "foo(bar(bar(foo)))(foo1)bar1"
...
A little fun with Java this time. I want to write a program that reads a code from standard input (line by line, for example), like:
// some comment
class Main {
/* blah */
// /* foo
foo();
// foo */
foo2();
/* // foo2 */
}
finds all comments in it and removes them. I'm trying to use regular expressions, and fo...
When I learned regular expressions I learned they should start and end with a slash character (followed by modifiers).
For example /dog/i
However, in many examples I see them starting and ending with other characters, such as @, #, and |.
For example |dog|
What's the difference?
...
Web frameworks such as Rails and Django has built-in support for "slugs" which are used to generate readable and SEO-friendly URLs:
Slugs in Rails
Slugs in Django
A slug string typically contains only of the characters a-z, 0-9 and - and can hence be written without URL-escaping (think "foo%20bar").
I'm looking for a Java slug funct...
I am looking at the code in the tumblr bookmarklet and was curious what the code below did.
try{
if(!/^(.*\.)?tumblr[^.]*$/.test(l.host))
throw(0);
tstbklt();
}
Can anyone tell me what the if line is testing? I have tried to decode the regex but have been unable to do so.
...
Hi guys,
I am using TinyMCE to publish content to my site. I have the problem whereby I can only insert an image inside another element, eg a paragraph, even if I place the cursor at the end of the content.
So, when I publish the content, I currently end up with markup like:
<p>Text content <img src="blah" /></p><p>Another paragraph</...
How can i check if a variable has something in it? I tried checking if a .match() returned null but that wasn't useful for checking with an OR?
All ideas would be gratefully appreciated!
...
I'm new to Perl and playing around screen scraping and regex. I'm trying to extract the "title" name of the following HTML block:
... title="The Valley Downs Chicago"><img class="vimg120" ...
My simple Perl code to do so is:
@htmlBlocks = split ("margin-bottom:20px",$content);
foreach $item (@htmlBlocks)
{
if (/\stitle="([^"]*)"/six)...
I have this string:
1001,"Fitzsimmons, Des Marteau, Beale and Nunn",109,"George","COD","Standard",,109,8/14/1998 8:50:02
What regular expression would I use to replace the commas in the
"Fitzsimmons, Des Marteau, Beale and Nunn" with a pipe | so it is:
"Fitzsimmons| Des Marteau| Beale and Nunn"
Should have clarified, I am doing a s...
I am writing temporary PHP script to update MySQL database of my vBulletin forum.
Here's what it does. It finds any entry that has a [youtube][/youtube] code. And then it has to replace that code with a link to the youtube video instead.
So, here is an example of what I have to take:
$string = <<<END
Hi everyone! Check out this video ...
is the regex [a-Z] valid and if yes then is it the same as [a-zA-Z]?
please note that in [a-Z] the a is lowercase and the Z is capital
Edit:
i received some answers specifiying that while [a-Z] is not valid then [A-z] is valid (but wont be the same as [a-zA-Z]) and this is really what i was looking for.
since i wanted to know in genera...
if I have a string in the format of
(static string) name (different static string ) message (last static string)
(static string) name (different static string ) message (last static string)
(static string) name (different static string ) message (last static string)
(static string) name (different static string ) message (last static...
in my web application i have text box and i want to prevent the user not start with white space and not start with digit and remaining letters alphanumarics help me thank u
...
How can I write a regex which will replace any file name, with it's folder path, but wouldn't match url? and wouldn't match in url? For example it should match:
/images/something.png
content/scripts/myscript.js
image.gif
/1.jpg
But should not match:
http://www.google.com/images/something.png
www.google.com/scripts/myscript.js
http://...