I need to convert a string like this:
tag, tag2, longer tag, tag3
to:
tag, tag2, longer-tag, tag3
To make this short, I need to replace spaces not preceded by commas with hyphens, and I need to do this in Javascript.
...
Is there any way to replace a regexp with modified content of capture group?
Example:
Pattern regex = Pattern.compile("(\\d{1,2})");
Matcher regexMatcher = regex.matcher(text);
resultString = regexMatcher.replaceAll("$1"); // *3 ??
And I'd like to replace all occurrence with $1 multiplied by 3.
edit:
Looks like, something's wrong :...
Hi, I'm trying to match the following using a regular expression in Java - I have some data separated by the two characters 'ZZ'. Each record starts with 'ZZ' and finishes with 'ZZ' - I want to match a record with no ending 'ZZ' for example, I want to match the trailing 'ZZanychars' below (Note: the *'s are not included in the string - ...
hi
There is an array of strings
paths = ['foo/bar_baz/_sunny', bar/foo_baz/_warm', 'foo/baz/_cold', etc etc]
I need to remove underscore in each last part of path (_sunny => sunny, _warm => warm, _cold => cold)
paths.each do |path|
path_parts = path.split('/')
path_parts.last.sub!(/^_/, '')
puts pat...
Hello there,
I'm trying to make my own BBCode parser for my website and I'm looking for a way to "htmlentities()" except the codes inside PRE tags, and the PRE tag itself.
For example:
<b>Hello world</b> (outputs <b>Hello world<>)
<pre>"This must not be converted to HTML entities"</pre> (outputs <pre>"This must not be conv...
Hi guys, i have to parse need string.
Here is command I execute in Linux console:
amixer get Master |grep Mono:
And get, for example,
Mono: Playback 61 [95%] [-3.00dB] [on]
Then i test it from python-console:
import re,os
print re.search( ur"(?<=\[)[0-9]{1,3}", u" Mono: Playback 61 [95%] [-3.00dB] [on]" ).group()[0]
And get re...
I want to remove dots in acronyms but not in domain names in a python string. For example,
I want the string
'a.b.c. [email protected] http://www.test.com'
to become
'abc [email protected] http://www.test.com'
The closest regex I made so far is
re.sub('(?:\s|\A).{1}\.',lambda s: s.group()[0:2], s)
which results to
'ab.c. [email protected]...
I'm revealing my embarrassing ignorance of REGEX-fu here, but: I currently have a website where a load of the articles' URLs are written as "article_name", whilst the newer ones are written as "article-name".
I want to move all of them to using dashes, so is there a regular expression I could use to rewrite the older URLs to their newer...
For the given text:
This text A,is separated,by a comma A,unpreceded by the uppercase A,letter A,ok?,
Expected matches:
This text A,is separated,
and
by a comma A,unpreceded by the uppercase A,letter A,ok?,
Please write a regex that would work like described. Preferably one that will work with .NET
...
Can anybody guide me in the right direction...
I have some folder strucktures that I want to check for a trailing / slash, some of the folders don't have a trailing / and if it does not have a trailing
/ I need to add one
If I use this regex it works but it replace the last character of the folder name
Folder/name/test
folder...
This should be very simple ( when you know the answer ). From this question
I want to give it a try to the posted solution. And my question is:
How to get the parameter value of a given url using javascript regexp?
I have:
http://www.youtube.com/watch?v=Ahg6qcgoay4
I need:
Ahg6qcgoay4
I tried:
http://www.youtube.com/watch\\?...
I can't for the life of me understand why the following regex can't match 4 floats.
there is a couple of rules for the way theese floats can be written.
the float ranges from 0 to 1
you can skip the first digit if its 0
there is an unlimited number of digits after the period.
Theese are valid floats
1
1.0
0.0
.0
0.123
.123
Now fo...
A little regex help please.
Why are these different?
Regex.Replace("(999) 555-0000 /x ext123", "/x.*|[^0-9]", String.Empty)
"9995550000"
Regex.Replace("(999) 555-0000 /x ext123", "[^0-9]|/x.*", String.Empty)
"9995550000123"
I thought the pipe operator did not care about order... or maybe there is something else that can explain thi...
$rex = '/^[^<,"@?=>|;#]$/i';
I'm having trouble with this regular expression. The idea is that the input fields are checked for certain characters and if present, throw an error.
This regex is throwing errors for every string longer than 1 character. Can anyone tell me what I'm doing wrong?
EDIT: People are saying they don't see what...
Hello,
I am searching a pure Delphi library with good full-Perl syntax support.
It should:
match groups (both named and numbered)
be able to match, replace, split
support look-ahead and look behind
come with source
be free
support Unicode
be compatible with Delphi 2009
Which library you prefer?
...
Hi,
I need to validate some user input that is encoded in UTF-8. Many have recommended using the following code:
preg_match('/\A(
[\x09\x0A\x0D\x20-\x7E]
| [\xC2-\xDF][\x80-\xBF]
| \xE0[\xA0-\xBF][\x80-\xBF]
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
| \xED[\x80-\x9F][\x80-\xBF]
| \xF0[\x90-\xBF][\x80-\xBF]{2}
| [\xF...
I need some Perl regular expression help. The following snippet of code:
use strict;
use warnings;
my $str = "In this example, A plus B equals C, D plus E plus F equals G and H plus I plus J plus K equals L";
my $word = "plus";
my @results = ();
1 while $str =~ s/(.{2}\b$word\b.{2})/push(@results,"$1\n")/e;
print @results;
Produc...
I've got a method that uses sp_sproc_columns to find all parameters that need to be send for a stored procedure.
My question is how can I do something similar for inline SQL querys?
I want to get a list of the parameters the query is expecting.
Would the only way achieving this will be to use Regular expression? Any examples?
Exam...
Is there a simple way to remove all characters from a given string that match a given regular expression? I know in Ruby I can use gsub:
>> key = "cd baz ; ls -l"
=> "cd baz ; ls -l"
>> newkey = key.gsub(/[^\w\d]/, "")
=> "cdbazlsl"
What would the equivalent function be in Python?
...
I want to "fix" all these URLs so, that all of the following URLs are valid (All the URLS are from the Domain "example.com":
before:
httpprache.htm
tech-z.htm
bla/blubbb.html
/suchen/bildung/schulen/abend.htm
/suchen/bildung/schulen/beruf.htm
www.google.de
http://www.google.com/asdf.html
https://blabla.com/
after:
http://example.com...