I have search strings, similar to the one bellow:
energy food "olympics 2010" Terrorism OR "government" OR cups NOT transport
and I need to parse it with PHP5 to detect if the content belongs to any of the following clusters:
AllWords array
AnyWords array
NotWords array
These are the rules i have set:
If it has OR before or afte...
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?
...
I have an input field in a form. Upon pushing submit, I want to validate to make sure the user entered non-latin characters only, so any foreign language characters, like Chinese among many others. Or at the very least test to make sure it does not contain any latin characters.
Could I use a regular expression for this? What would be th...
Hi All,
I am wondering on where to begin to perform the following replace in regex:
Read file (.cs file)
Replace anything between quotations ("e.g:") with its uppercase version ("E.G:")
By example:
string m = "stringishere";
Becomes
string m = "STRINGISHERE";
Thanks in advance,
Kyle
...
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 ...
I think I've written maybe one shell script my entire life, and I'm not even sure if it's possible to do this, but I'm trying to write a script that will ftp the contents of a directory, one at a time. That is, it'll ftp one and then close the connection, then ftp the second, and close that etc. This is because there may be up to five ...
I need to find the most efficient way of matching multiple regular expressions on a single block of text. To give an example of what I need, consider a block of text:
"Hello World what a beautiful day"
I want to replace Hello with "Bye" and "World" with Universe. I can always do this in a loop ofcourse, using something like String.repl...
I am using a lib which uses
eregi($match="^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$",$line,$matches)
but as eregi is deprecated now, i want to convert above to preg_match. I tried it as below
preg_match($match="/^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$/i",$line,$matches)
but it throws an error saying Unknown modifier ...
Given a string in the format: XXX999999v99 (where X is any alpha character and v is any numeric character and v is a literal v character) how can I get a regex to match the numeric characters following the v? So far I've got 'v\d\d' which includes the v but ideally I'd like just the numeric part.
As an aside does anyone know of a tool ...
I'm building a CMS for a scientific journal and that uses a lot of Greek characters. I need to validate a field to include a specific character set and Greek characters. Here's what I have now:
[^a-zA-Z0-9-()/\s]
How do I get this to include Greek characters in addition to alphanumeric, '(', ')', '-', and '_'?
I'm using C#, by the ...
I have a string which is basically a list of "words" delimited by commas. These "words" can be pretty much any character e.g. "Bart Simpson, Ex-girlfriend, dude, radical"
I'm trying to use javascript, jQuery, whatever i can to replace a word based on a search string with nothing (in essence, removing the word from the list).
For exampl...
I'm trying to convert the John Resig's Templating Engine to work with PHP.
Essentially what I would like to achieve is the ability to use certain Kohana Views via a JavaScript templating engine, that way I can use the same views for both a standard PHP request and a jQuery AJAX request.
I'm starting with the basics and would like to be...
My pattern looks something like
<xxxx location="file path/level1/level2" xxxx some="xxx">
I am only interested in the part in quotes assigned to location. Shouldn't it be as easy as below without the greedy switch? Does not seem to work :(
/.*location="(.*)".*/
...
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'm trying to call the jQuery text() function and run it through the trim() function to remove all trailing and leading whitespace. Seems to work great in Firefox, however, does not work in IE7 (refuses to remove a space trailing at the end).
Any ideas?! Maybe a regex solution?
...
I know that the following works but it is not that readable, is there any way to make it more readable in the code itself without the addition of a comment?
//Start her off
String sampleregex = "\\\\";
if (input.matches(sampleregex))
//do something
//do some more
...
I need a regular expression that will extract sentences from text that contain a year in them.
Example text:
Next, in 1988 the Bradys were back
again for a holiday celebration, "A
Very Brady Christmas". Susan Olsen
(Cindy) would be missing from this
reunion, Jennifer Runyon took her
place. This was a two hour movie in
wh...
im new with regexp, so can i ask for some assistance
Using string.replace function what code that can replace spaces with comma
Input:The quick brown fox jumps over the lazy dog.
Output:The,quick,brown,fox,jumps,over,the,lazy dog.
Thanks
...
I want a Perl regular expression that will match duplicated words in a string.
Given the following input:
$str = "Thus joyful Troy Troy maintained the the watch of night..."
I would like the following output:
Thus joyful [Troy Troy] maintained [the the] watch of night...
...
Hi,
I'm trying to use a Regex expression I've found in this website and it doesn't seem to work. Any ideas?
Input string:
sFetch = "123<script type=\"text/javascript\">\n\t\tfunction utmx_section(){}function utmx(){}\n\t\t(function()})();\n\t</script>456";
Regex:
sFetch = Regex.Replace(sFetch, "<script.*?>.*?</script>", "", RegexOpt...