Hi,
I am attempting to parse the video ID of a youtube URL using preg_match. I found a regular expression on this site that appears to work;
(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n]+
As shown in this pic:
My PHP is as follows, but it doesn't work (gives Unknown modifier '[' error)...
<?
$subject = "http://www....
Is there a way to search for multiple nested if statements in code using a regular expression?
For example, an expression that would locate an instance of if statements three or more layers deep with different styles (if, if/else, if/elseif/else):
if (...) {
<code>
if (...) {
<code>
if (...)
<code>
...
Hi All,
I am working writing a regular expression used to validate string in C. Here is to what I have gone so far
'^"[A-Za-z0-9]*[\t\n]*"$'
for rules
- A string should begin with double quotes
- May not contain a newline character
However, I am not able to capture the rule for allowing '\' or '"' in a string if preceded with '\'. H...
I have text files formatted as such:
R156484COMP_004A7001_20100104_065119.txt
I need to consistently extract the R****COMP, the 004A7001 number, 20100104 (date), and don't care about the 065119 number. the problem is that not ALL of the files being parsed have the exact naming convention. some may be like this:
R168166CRIT_156B2075_S...
What is wrong with this regexp? I need it to make $name to be letter-number only. Now it doens't seem to work at all.
if (!preg_match("/^[A-Za-z0-9]$/",$name)) {
$e[]="name must contain only letters or numbers";
}
...
Hello guys, I'm not very familiar with regEx's and I'm trying to find a preg_match regex for searching for any of the following strings within a file and if found it will halt it. I already have the fopen and fgets and fclose setup I just need to use a regex inside of a preg_match for the following php tags:
<?php
<?
?>
so if preg_mat...
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 tu...
Hi,
I have a variable, $var, that contains a string of characters, this is a dynamic variable that contains the values from inputs.
$var could be 'abc', or $var could be 'blu',
I want to match the string inside variable against an array, and return all the matches.
$array = array("blue", "red", "green");
What is the correct syntax...
I am trying to match any url that has /images/ , /styles/ , or /scripts/ in a lighttpd $HTTP["url"] statement. How could this be done? I am currently using "^/images/" , etc. and it's only working if that directory is in the beginning of the URL.
...
In a url like the one below, I'd like to get the value of ProdId. The URL format will always be consistent, as will the parameter name, but the length of the value may change. It will always be numeric.
http://www.example.com/page.php?ProdId=2683322&xpage=2
Using PHP what's the fastest way to get it (I'll be processing 10,000's so...
e.g
string = "This is a re@lly long long,long! sentence";
becomes
string = "This is a long sentence";
Basically so all non-alphanumeric words or removed keeping spaces in tacked
Any ideas?
...
I have a list of files that look like this:
Input
/foo/bar/baz/d4dc7c496100e8ce0166e84699b4e267fe652faeb070db18c76669d1c6f69f92.mp4
/foo/baz/bar/60d24a24f19a6b6c1c4734e0f288720c9ce429bc41c2620d32e01e934bfcd344.mp4
/bar/baz/foo/cd53fe086717a9f6fecb1d0567f6d76e93c48d7790c55e83e83dd1c43251e40e.mp4
And I would like to split out the filen...
I have something of a a hairy problem, I'd like to generate a couple of paragraphs of "description" of a given url, normally the start of an article. The Meta description field is one way to go but it isn't always good or set properly.
It's fair to say it's a bit problematic to accomplish this from the screenscraped HTML. I had a gener...
I have a PHP regex that I want to fail if the matched word after /blog is just feed.
This MUST be done within the regex itself, not using any other PHP syntax.
The regex currently looks like this:
blog/([a-zA-Z0-9\-]+)
What would I add to this to properly negate the regex if feed is found after blog/?
...
Hi,
I have so many println("") in my codes .. I know it is messy ... I want to put comment for each of the println("");
how to do that in VIM ? I mean I want to do that on multiple files.
Also if possible, can it detect whether the lines has // already or not ... if the lines has been commented .. I don't want to add new //
...
For example: an youtube embed code
<object width="480" height="385">
<param name="movie" value="http://www.youtube.com/v/TFlzeO267qY&hl=en_US&fs=1&"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://...
Hi,
How can I search a whole string for a specific match.
It'll contain both characters with int or decimal numbers
eg A12B32.25C-456D-75.E75
I'll know that this will start with A and ends with E
I think I can use "^" and "$" right?
but i'm bit lost in other parts to check for character and int or decimal.
I'll be glad if you can give t...
hello!
I need to extract the zipcode from file's line.
each line contains an adress and is formatted in a different way.
eg.
"Großen Haag 5c, DE-47559 Kranenburg"
or
"Lange Ruthe 7b, 55294 Bodenheim"
the zipcode is always a five digit number and sometimes follows "DE-".
I use Java.
Thanks a lot!
...
Hi
I want to remove characters from a string other then a-z, and A-Z. Created following function for the same and it works fine.
public String stripGarbage(String s) {
String good = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
String result = "";
for (int i = 0; i < s.length(); i++) {
if (good.indexOf(s.ch...
I have a text string, for ex. 'A vehicle travels from A to B, distance {$d} km at constant speed. While returning back to A on same path it {$variation} its speed by {$v} km/hr. The total time of journey is {$t} hours. Find the original speed of vehicle.'
The variables in the curly brackets are to be replaced by appropriate latex equat...