Hi,
I'm used to play with regexp in languages where I can use parenthesis to capture references. The only thing near that in flex that I'm seeing is the yytext variable. But it's contents are the full matched regexp and not just some part of it.
Isn't the use of back references in flex possible? If so, how can I do it? I can't find any...
I want that find empty tags, here is a example
txt ="<lol1><><lol2>"
rgx = "<([a-zA-Z_0-9]+)>"
print re.findall(rgex, txt)
I get this
['lol1', 'lol2']
I want
['lol1', '', 'lol2']
How I can do this with regex?
...
I need a regex that will give me the following results from each example and I can't seem to get it right:
example.com yields -> nothing / empty
www.example.com yields -> nothing / empty
account.example.com yields -> account
mywww.example.com yields -> mywww
wwwboys.example.com yields -> wwwboys
cool-www.example.com yields -> cool-...
I'm looking to learn how to create a REGEX in Coldfusion that will scan through a large item of html text and create a list of items.
The items I want are contained between the following
<span class="findme">The Goods</span>
Thanks for any tips to get this going.
...
Hello, can someone help me with a javascript regex question?
I am trying to replace all the digit dates in a string to a formatted version.
This is what I have so far
txt = txt.replace(/\d{10}/g, 'Formatted Date Here');
Is this possible? Any help is greatly appreciated! Thanks!
...
Hi All,
Here's the regular expression I use, and I parse it using CAtlRegExp of MFC :
(((h|H?)(t|T?)(t|T?)(p|P?)(s|S?))\://)?([a-zA-Z0-9]+[\.]+[a-zA-Z0-9]+[\.]+[a-zA-Z0-9])
It works fine except with one flaw. When URL is preceded by characters, it still accepts it as a URL.
ex inputs:
this is a link www.google.com (where I can j...
I'm no expert on Regex. I'm trying to create a regular expression that will match the exact same number of opening and closing braces, but I'm stumped on how to do it.
An example:
nothing: important, a b { c {{{ a another {{ nothing }} }}} }
or:
one { two {{ error, forgot ending brace }}
The problem is that I don't know how many b...
I am using Tuckeys UrlRewrite filter for getting clean urls on my java application. I redirect all the requests to a certain resource to a spring request dispatcher. Here is my original rule
<rule>
<from>(.*)$</from>
<to>$1.htm</to>
</rule>
Problem is that accessing .js, .css files also seem to be redirecting. I want to know h...
I do not not know much about Regex, I want to try parsing sting from database according to flowing instructions.
I know that I am need to use CLR but for begin I want to learn Regex
Data in tables look like
create table #tempTBL (opis varchar(40))
go
insert into #tempTBL
select 'C 136'
union
select 'C 145'
union
select 'C146'
union ...
I want to take the youtube embed code that youtube provides and use a regex to convert it to valid FBML code i.e. use the fb:swf tag. Has anyone done something like this?
So far the regex I've come up with is :
preg_replace('/<object(.*)<\/object>/i', "Whatever I need here...", $str);
I know its lame but its my first try.
Thanks for ...
I have a string
$str = 'abcde-da__123123213.xef';
$str2 = 'asdfasd__2342352353.gff';
$str3 = 'twethe__3242323423.pig';
I want to replace anything following __ (2 underscores) and before the . (dot) with a new string (number). For example, the above $str changes to 'abcde-da__23235239.xef'.
One of the ways is to
$temp = explode('.'...
I have a string like so:
http://www.youtube.com/v/Nnp82q3b844&hl=en_US&fs=1&
and I want to extract the
Nnp82q3b844
part of it i.e. the part between /v/ and the first &.
Is there and easy way to do this in PHP?
...
I want to use this regular expression in Python:
<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>
(from http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/)
def removeHtmlTags(page):
p = re.compile(r'XXXX')
return p.sub('', page)
It seems that I cannot directly substitute the complex r...
Is the syntax for writing regular expression standardized? That is, if I write a regular expression in C++ it will work in Python or Javascript without any modifications.
...
I have found two ways to extract matches in Python:
1.
def extract_matches(regexp, text):
matches = re.match(regexp, text)
if matches:
return matches.group(1)
2.
def extract_matches(regexp, text):
try:
return re.findall(regexp, text)[0]
except IndexError:
return None
Which one would you suggest me to use? And d...
"CamelCase".replace(/[A-Z]/g, " $1")
Produces
>>" $1amel $1ase"
How to replace all occurrence of camel cases.
...
I have a string, populated from the *nix "hostname" command, that I need to parse for a number. That's the easy part. The difficulty comes from a need to have to Do Math(tm) on that captured number. Apparently regex captures are always of type MatchData, which doesn't have any math functions like 'add' or 'modulo', nor does it have a ...
(?P<id>\d*)(/(?P<title>.*))?
Most of the time,we use regex to match something,but how to generate the matching string if we have id and title already?
Example,if id=4 and title='hello world',the result should be:
4/hello world
But if we only have id=4,it should be:
4
Because as the regex indicates,title is optional.
Two answers...
This is an example that searches PDF files in the current directory.
import os, os.path
import re
def print_pdf (arg, dir, files):
for file in files:
path = os.path.join(dir, file)
path = os.path.normcase(path)
if re.search(r".*\.pdf", path):
print path
os.path.walk('.', print_pdf, 0)
Could anyone explain what r".*\.pdf" m...
Hi There
I have a simple question how do I remove a \ with regex?
Thanks
I have tried it like this .replace(/\\/ig, '');
I am using javascript and classic asp
Now it works: .replace(/\\/ig, ''); somehow the first time I tried it, it were not working! - Thanks for all the quick answers!
...