Regular expressions (often shortened to "regex") are a declarative language used for pattern matching within strings. Please also include a tag specifying the programming language or tool you are using.
0
votes
1answer
14 views
Linq Regex for whole word search
I'm unable to find a recent decent answer on this.
Linq does not support regex, and trying to extract a method out does not outsmart the framwork. How do I do a whole work match on a list of ...
0
votes
3answers
22 views
Perl's grep gives different results when used with or without qr
I'm trying to use grep with a variable regex. I assumed that the following program would print nothing, since the regex /food/ doesn't match any of the items in my array.
#!/usr/bin/perl
use strict;
...
0
votes
2answers
15 views
What is the perl equivalent of PHP's preg_quote function?
I have a string that I want to match within a perl regex pattern, but characters in it may need escaping. In PHP, the function that does this is preg_quote. What is the equivalent in perl?
1
vote
5answers
61 views
Python Removing last character _ from string using regex
I know there are a bunch of other regex questions, but I was hoping someone could point out what is wrong with my regex. I have done some research into it and it looks like it should work. I used ...
0
votes
1answer
14 views
Django urlpatterns won't match
I have urlpatterns that aren't matching. This is something I'm adapting from the Django tutorial. It's probably something easy, but I'm just missing it.
The error:
Page not found (404)
Request ...
0
votes
3answers
40 views
Replacing inner nested quotes in a string using Regular Expression
I have a String: "The name is "Rambo"."
I would like to replace the inner quotes with " using regex so the output would look like:
"The name is "Rambo"."
0
votes
3answers
22 views
Finding inner matches using Regular Expressions in Javascript
If I have a string "#review?loanId=12-00034&docId=0" and need to select the loanId ("12-00034") string, how would I use a single regular expression to do this?
So far I can use /loanId=[\d-]*/ to ...
0
votes
2answers
46 views
Regex pattern search starts with 2 letters OR 2 numbers
I'm writing a javascript function to detect a correct entry into the database before sending it. The variable must start with either 2 digits OR 2 letters followed by 2 more letters then 3 digits. I ...
4
votes
3answers
37 views
extracting text from a column using regexp_substr
I have a table with a varchar column with data like this:
"<tasa>
<parametros>
<parametro>
<nombre>ea</nombre>
<valor>35</valor>
...
0
votes
1answer
24 views
A simple xml parser specific to R
I've read the SO questions about why never to use regex on {HT,X}ML, such as this one -- Regex to Indent an XML File , but I thought I'd post a function I wrote that does absolutely nothing but indent ...
0
votes
1answer
39 views
Javascript regular expression to find double quotes between certain characters
I'm trying to create a string that can be parsed into JSON. The string is dynamically created based on the content in a CMS.
That content could contain HTML markup with double quotes, which confuses ...
1
vote
2answers
22 views
Making group constraints in Regex in android
So I have this String:
String articleContent = "dfgh{jdf%g{%qf234ad%22!#$56a%}vzsams{%3%45%}678456{78";
I want to remove everything between {% %}
So result would be something like :
...
3
votes
2answers
55 views
Regular Expression - Match But Exclude?
I have a very simple task of which I am trying to find and replace special characters within a string. My regex is working but sometimes there are italics tags within the string which I do not want to ...
0
votes
4answers
62 views
Get URL from string with text
I have a bunch of strings like this:
Some text, bla-bla http://www.easypolls.net/poll.html?p=51e5a300e4b084575d8568bb#.UeWjBcCzaaA.twitter
And I need to parse this String to two:
Some text, ...
-1
votes
2answers
46 views
PHP basic regular expression [duplicate]
For example i've this kind of content
<div id="t1" class="tt" tag='t2"><div class="t3">tee</div><a ...
0
votes
3answers
54 views
Split by space but not newline
I am trying to convert all links in a given string to clickable a tags using the following code :
String [] parts = comment.split("\\s");
String newComment=null;
for( String item : parts ) try {
...
1
vote
3answers
41 views
PHP .htaccess removing .php extension and language directory to parameter
I'm looking for a regulair expression for a .htaccess file inside my PHP server.
What I want is that it detects the language from the first directory as parameter:
nl
en
be
de
Any other options ...
1
vote
3answers
43 views
Substitution with \s does not work as expected
I write regex to remove more than 1 space in a string. The code is simple:
my $string = 'A string has more than 1 space';
$string = s/\s+/\s/g;
But, the result is something bad: ...
0
votes
2answers
51 views
Why does adding a character class to the end of a regex fail to match hex numbers?
Perl accepts:
my @resultado = $texto =~ /[^g-zG-z]$RE{num}{real}{-base=>16}/g
but doesn't accept:
my @resultado = $texto =~ /[^g-zG-z]$RE{num}{real}{-base=>16}[^g-zG-z]/g
I just add ...
4
votes
6answers
64 views
Confused about regular expression
In the book Programming Collective Intelligence there is a regular expression,
splitter = re.compile('\\W*')
From context it looks like this matches any non-alphanumeric character. But I am ...
1
vote
2answers
22 views
Selectively deleting commas and splitting strings
I have s string that looks like
txt = '"EMB","iShares J,P. Morg",110.81,N/A'
I'm using strsplit(txt,','); to break this into separate strings based on the comma delimiter. However I want to ignore ...
0
votes
3answers
37 views
How to find acronyms in a pdf file
In my thesis I need to add a list of acronyms. I wondered how it can be programmed. I've found the nice utility pdfgrep, which also gets regular expressions. I used it in such a way:
pdfgrep ...
1
vote
3answers
54 views
return substring match
I am trying to get just a part of a string with a regex
this is the string i am testing
class1 container _box _box_CEC493
the string is a series of classes applied to an element.
what i would like ...
0
votes
1answer
18 views
Find and replace to remove the icon in all my forms
I'm using Visual Studio, and I would like to remove the icon in all the forms on my code. The icon is embedded in the resx files, so I used the following regular expression to find the icon, then I ...
3
votes
4answers
25 views
Trouble with non-capturing groups in regular expression
I'm attempting to capture the 6 digit number in the following:
ObjectID: !nrtdms:0:!session:slonwswtest1:!database:TEST:!folder:ordinary,486150:
I tried the following regex:
\d+(?::$)
attempting ...
0
votes
1answer
33 views
Is there any regexp replacement?
Yesterday I've been lost, when I tried to produce a regexp with regexp, I've failed to escape out the escaped escapes (for JavaScript). Regexps are great for CLI Unix pipe chains and in ...
1
vote
1answer
13 views
Hibernate Regexp MySQL
I ask this question to show how MySQL and Hibernate work each other with Regular Expressions.
The problem:
SELECT * FROM table WHERE regexp column '\d'
Solution:
Go to my answer.
Hope this ...
1
vote
2answers
16 views
jQuery: Search for div containing specific mark up
I'm stuck with a editor that outputs <p><br></p> when the textfield is empty and now I want to target the divs with that none content.
I've been trying .filter, text lengths, ...
0
votes
3answers
94 views
Most efficient way of splitting many strings
My current project handles large numbers of incoming radio messages (~5M per day) represented as strings that must be then divided into pre-determined sized chunks, ready for storage.
For example, a ...
0
votes
1answer
17 views
.htaccess alternative to B flag? (escape backreferences)
I have a .htaccess set up with the following:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ profile.php?aid=$1 [L,QSA]
This gets a users ...
-1
votes
2answers
33 views
Python extract value beautifulsoup regex [on hold]
I have the below through regex and beautifulsoup. I need to extract the UID value e.g 5968723334.
[u'/home.html', u'browse_settings.html', u'browse.html?', u'test.html?uid=5415292833', ...
0
votes
1answer
23 views
JS - Regular Expression for 12hr Time Matching
I am attempting to take this regular expression that is currently being used in a java application and use it with javascript.
(1[012]|[1-9]):[0-5][0-9](\\s)?(?i)(am|pm)
However, I am running into ...
2
votes
2answers
28 views
Creating a keyword based search in python
I have a giant CSV file with close to 6K entries and the file looks something like this:
PDB ID NDB ID Structure Title Citation Title Abstract
1ET4 1ET4 Structure of Solution ...
-1
votes
1answer
20 views
How do I use regex with vQmod?
Once again, I am stuck with some regex and I don't really know where to start.
I am using vQmod to build an OpenCart extension and I want to be able to search all files that have this code:
if ...
8
votes
1answer
75 views
Better Way to Write Regular Expression
So, I've been trying to write out a regular expression for something like a resistance value, which contains a certain amount of digits and at most one letter, but is always a certain amount of ...
0
votes
1answer
19 views
Spiting Regular expression and accessing Array of Array
An example am trying to understand from website.
People2.txt is as follows.
2323:Doe John California
827:Doe Jane Texas
982982:Neuman Alfred Nebraska
I don't get the output as shown from the ...
1
vote
0answers
30 views
Converting JSON string to lisp(aml) readable string for evaluation using regular expressions
I'm trying to convert a JSON string to a stringformat that I can use to evaluate in Lisp (aml).
I want to convert f.eks.:
{"id": 1, "name": "Foo", "price": 123, "tags": ["Bar","Eek"], "stock":
...
0
votes
1answer
13 views
std::regex_match() freezes my program
So here is my program:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <regex>
#include <windows.h>
using namespace std;
int _tmain(int argc, _TCHAR* ...
0
votes
1answer
30 views
Can't match RewriteRule
I need to do a very simple URL rewrite but my RewriteRule is not working.
I want this URL: http://myweb.com:8080/MySite/bla?bla
To become this: http://myweb.com:8080/MySite/index.php
My .htaccess ...
0
votes
2answers
24 views
Add some text in loaded xml using Javascript and regex
I have loaded an SVG file into memory in javascript.
I want to manipulate this data in memory using the Javascript replace function.
As you notice, there are many 'g' elements. I want to wrap them ...
0
votes
1answer
60 views
Count the occurrences of word by pattern in R
Perhaps an oft asked question, am royally stuck here.
From an XML File, I'm trying to search for all occurrences, their lines and the total count of occurrence of each 12 character string containing ...
0
votes
0answers
82 views
What regular expression does Facebook use to parse the 'fields' parameter?
We are currently working on improving our REST API and we need to implement the optional 'fields' parameter for some actions. Therefore, we would like it to recognize the pattern of the request in the ...
0
votes
2answers
46 views
How to combine these regex requirements?
I'm using an Asp.Net RegularExpressionValidator to validate phone numbers.
The check is quite basic - a number can be 10 or 11 characters in length, all numeric and starting 01 or 02.
Here's the ...
0
votes
1answer
23 views
preg_replace a string, get piece of string an insert into a function
i have not struggled to understand some regex, but i can't get it right. I am developing a system that understand some codes ind a included file. Simple. But i need to get some pieces from the string ...
1
vote
1answer
14 views
R: How to unTag the Sentence, after tagged by tagPOS
I have tagged part of Speech to an string using tagPOS
Now I want to unTag the string and get back as it was previous.
library(openNLP)
str <- "this is the a demo string. Which is used to show ...
1
vote
2answers
58 views
Replace <p> </p> with <br /> with condition
In wordpress I am outputting some <div>s along the content of my shortcode. The problem is because wordpress puts paragraphs inside <p></p> tags, the line is broken where the ...
0
votes
1answer
29 views
Validate the file name and file type in type=“file”
I have the following code to see if type="file" with the id file has been changed.
$('body').on('change', '#file', function() {
// Do something
});
When I have choose a file I want to see if ...
1
vote
1answer
20 views
PHP - preg_match_all Same Group, Different Pattern
<?php
$str = '123.456.789.987,654,321,';
// preg_match_all('((?<grp1>\d{3})\.|(?<grp2>\d{3})\,)', $str, $matches);
...
0
votes
1answer
14 views
.htaccess Regex to rewrite path
I have a very specific requirement and I pretty much suck at regular expressions to put it bluntly.
A program generates images of various sizes and puts them in a folder which is the same name as the ...
1
vote
1answer
23 views
.htaccess difficulties with directory
I want to following url :
nl/provincies/Limburg/plaats/#CITY#
for example :
nl/provincies/Limburg/plaats/Amsterdam
To be rewriten to section.php?sid=plaatsen$plaats=#CITY#
Ofcourse this is not so ...