Все вопросы: [regex]

3 742 вопросов

0
голосов
2ответов
179 просмотров

Regular expressions question

I've got the following string : const std::string args = "cmdLine=\"-d ..\data\configFile.cfg\" rootDir=\"C:\abc\def\""; // please note the space after -d I'd like to split it into 2 substrings : std::str1 = "cmdLine=..."; and std::str2 = "rootDir=..."; using boost/algorithm/string.hpp ....

3
голосов
4ответов
6681 просмотров

Regular expression to extract all words starting with colon

I would like to use a regular expression to extract "bind variable" parameters from a string that contains a SQL statement. In Oracle, the parameters are prefixed with a colon. For example, like this: SELECT * FROM employee WHERE name = :variable1 OR empno = :variable2 Can I use a regular exp...

3
голосов
2ответов
2041 просмотров

extracting a number from a string in Java

I have a string with a number inside and I want to retrieve that number. for example if I have a string "bla bla 45 bla bla" I want to get the number 45. I have searched a bit and found out that this code should make the work Matcher matcher = Pattern.compile("\d+").matcher("bla bla 45 bla bla")...

1
голосов
2ответов
1282 просмотров

How to write regex to extract FlickR Image ID From URL?

I'm looking to do do two things, and I am looking to do them in a beautiful way. I am working on a project that allows users to upload flickr photos by simply entering their flickr image URL. Ex: http://www.flickr.com/photos/xdjio/226228060/ I need to: make sure it is a URL that matches the f...

0
голосов
2ответов
135 просмотров

Eliminating Characters using PHP PCRE

If I have a string $random, and I want to throw out everything except commas and numbers, how could I do this in PHP PCRE? I know \d will match numbers, but I don't get the rest of PCRE.

0
голосов
5ответов
1292 просмотров

Regex challenge: Match phrase only if outside of an <a href> tag</a>

I am working on improving our glossary functionality in a custom CMS that is running with classic ASP (ASP 3.0) on IIS with VBScript code. I am stumped on a regex challenge I cannot solve. Here is the current code: If InStr(ART_ArticleBody, "href") = False then sql="SELECT URL, Term, Re...

0
голосов
1ответов
148 просмотров

finding instance of text in sql files after WHERE clause

I have a VS2008 solution with a database project, in it is a folder that holds a whole bunch of sql stored procedures (we are talking 100's). Due to a change that has been made to the ANSI_NULLS setting for all the sprocs I need to update all instances of '= null' to 'is null'. I cannnot do a "...

5
голосов
1ответов
509 просмотров

Dealing ASP.net Routes with n slashes using regex

I need to use a URL like this: http://mydomain.com/Box/Categ1/Categ2/Categ3/.../CategN/id1,id2,id3,...,idN Then I tried to create a new route this way... routes.MapRoute( "Box", "Box/{data}", new { controller = "Box", action = "Index"}, new { data = @"([a-zA-Z0-9-,]+/?)+" } ); ...

30
голосов
5ответов
72516 просмотров

RegEx Pattern to Match Only Certain Characters

I'm a newbie to RegEx, and this particular issue is flummoxing me. This is for use with a JavaScript function. I need to validate an input so that it matches only these criteria: Letters A-Z (upper and lowercase) Numbers 0-9 The following additional characters: space, period (.), comma (,), pl...

0
голосов
1ответов
106 просмотров

Pulling RegEx from MySQL into PHP

I am trying to get the regex string from a table, but as soon as I put it into preg_match it throws an error about an unexpected "\". If I use the exact same string directly there is no issue.

0
голосов
2ответов
305 просмотров

to remove href attr from all the anchor tags using Reg Ex

i am trying to remove href attr from all the anchor tags using Reg Ex,for print page. Although i need the text value in anchors.

0
голосов
2ответов
174 просмотров

popluating multiple id tags

How can i populate multiple id tags simultaneously. On my page i have id tags starting with "total_" phrase, like total_1, total_2 etc., is there a way by which i can populate each of them on a single click in javascript. Should i use regex or parser. Any help will be highly appreciated. Than...

0
голосов
2ответов
161 просмотров

How to match a string with an optional part?

We have a string that we need to parse using regex, the string could be either: There was a problem at XXXX There was a problem at XXXX, previous failures were YYY The XXX could be any character (e.g. ".") How can we make regex that will match: XXXX ", previous failures were YYY" (remember...

0
голосов
1ответов
964 просмотров

Getting spaces with Boost::regex

I have a chunk of text like: Name=Long John Silver;Profession=cook;Hobby=Piracy And using the Boost::regex library I am trying to get the value of each attribute so I have the following regular expression for Name: regex(".*Name=([^;$]*).*") I understand it as "get everything after Name= u...

2
голосов
6ответов
475 просмотров

How to verify regexp patterns?

What are the common ways to verify the given regex pattern works well of the given scenario and check the results ? I would like to know in general , not in the particular programming language and what is the best way to learn about writing regular expression ?

2
голосов
2ответов
3864 просмотров

Regex 2 digits separated by commas, not all required

I need a regex for the following input: [2 digits], comma, [two digits], comma, [two digits] The 2 digits cannot start with 0. It is allowed to only enter the first 2 digits. Or to enter the first 2 digits, then a comma en then the next 2 digits. Or to enter the full string as described abo...

1
голосов
3ответов
1567 просмотров

Extracting info from html using PHP(XPath), PHP/Python(Regexp) or Python(XPath)

I have approx. 40k+ html documents where I need to extract information from. I have tried to do so using PHP+Tidy(because most files are not well-formed)+DOMDocument+XPath but it is extremely slow.... I am advised to use regexp but the html files are not marked up semantically (table based layout...

3
голосов
5ответов
6177 просмотров

Check if a string contains a certain number

I have a string 8,7,13,14,16 Whats the easiest way to determine if a given number is present in that string? $numberA = "13"; $string = "8,7,13,14,16"; if($string magic $numberA){ $result = "Yeah, that number is in there"; } else { $result = "Sorry."; } Looking for magic.

1
голосов
1ответов
2419 просмотров

How can i give password validation in flex

I want the validator for password text input. At least one Upper case letter At least one numeric character At least one special character such as @, #, $, etc. should be there in password how can i give it in action script or mxml.please help me. Thanks.

4
голосов
1ответов
1292 просмотров

Locale-aware Perl regular expressions (matching word boundaries)

I'm currently somewhat stuck getting a regular expression in Perl (taken from an earlier question of mine) to match word characters from a non-ASCII locale (i.e., German umlauts). I already tried various things such as setting the correct locale (using setlocale), converting data that I receive ...

0
голосов
3ответов
1343 просмотров

regex / instr javascript function to check url

I have 8 possible URL structures that I need to check in my javascript code and then run a function if the current page meets the correct criteria. There are 8 possible variations of the URL and all will include the keyword questions, so the first check needs to isolate and identify if the curre...

1
голосов
3ответов
350 просмотров

Replace strings in file

I have to replace in a following manner if the string is "string _countryCode" i have to replace it as "string _sCountryCode" as you can see where there is _ I replace it with _s followd be next character in capitals ie _sC more examples: string _postalCode to be replaced as string _sPostalCo...

1
голосов
2ответов
173 просмотров

Regex commas to spaces

i need a regex that converts commas to spaces. I know this is super simple, but i do not know regex. thanks. tag1, tag2, tag3, tag4,tag5 tag6 to tag1 tag2 tag3 tag4 tag5 tag6 thanks

0
голосов
10ответов
2256 просмотров

Regex which ignores comments

being a regex beginner, I need some help writing a regex. It should match a particular pattern, lets say "ABC". But the pattern shouldn't be matched when it is used in comment (' being the comment sign). So XYZ ' ABC shouldn't match. x("teststring ABC") also shouldn't match. But ABC("teststri...

0
голосов
4ответов
1824 просмотров

Java Regexp: UNGREEDY flag

I'd like to port a generic text processing tool, Texy!, from PHP to Java. This tool does ungreedy matching everywhere, using preg_match_all("/.../U"). So I am looking for a library, which has some UNGREEDY flag. I know I could use the .*? syntax, but there are really many regular expressions I ...

0
голосов
2ответов
160 просмотров

How can I find all matches of <element>something</element> with a regex?

So let's say that I have: &lt;any_html_element&gt;maybe some whitespaces &lt;br/&gt;Some text&lt;/any_html_element&gt; And I want to remove the first &lt;br/&gt; after &lt;any_html_element&gt;. How can I do that?

-1
голосов
3ответов
1440 просмотров

Sort lines on webpage using javascript/ regex

I'd like to write a Greasemonkey script that requires finding lines ending with a string ("copies.") &amp; sorting those lines based on the number preceding that string. The page I'm looking to modify does not use tables unfortunately, just the br/ tag, so I assume that this will involve Regex: ...

0
голосов
3ответов
122 просмотров

How can I find all matches of '{{**** *** **}}' with a regex?

I'm trying to extend PHP Markdown to allow the use of {{ and }} around some parts of the text (they will become search keywords, like a tag). I have this basic regex that kinda works: preg_match_all("/\{\{(.*)\}\}/", $description, $nomsTags); Except it doesn't work when there are 2 keywords i...

1
голосов
3ответов
1996 просмотров

Mysql text extract with Regex

I tried to extract text from html text stored in a db. This is an example: &lt;P style="FONT-SIZE: 13px; MARGIN-LEFT: 6px"&gt;&lt;FONT color=#073b66&gt;&lt;STRONG&gt;&lt;A href="/generic.asp?page_id=p00497"&gt;Practice Exams&lt;/A&gt; - &lt;/STRONG&gt;&lt;FONT color=#000000&gt;ours are the mo...

0
голосов
2ответов
128 просмотров

Regex From .NET to Python

I have a regular expression which works perfectly well (although I am sure it is weak) in .NET/C#: ((^|\s))(?&lt;tag&gt;\@(?&lt;tagname&gt;(\w|)+))(?($|\s|\.)) I am trying to move it over to Python, but I seem to be running into a formatting issue (invalid expression exception). It is a lame ...