Can anyone give me a Java regex to identify repeated characters in a string? I am only looking for characters that are repeated immediately and they can be letters or digits.
Example:
abccde <- looking for this (immediately repeating c's)
abcdce <- not this (c's seperated by another character)
...
I have a long string and I need to find instances of '#!#'+some text+'#!#'
right now I have:
string.replace(/(#!#*#!#)/g,
function (m) {....});
I need the whole thing passed into a function like that so that I can replace them correctly.
However, I want m to only be equal to what lies between the two #!#..I want this part....
I have a string which has several html comments in it. I need to count the unique matches of an expression.
For example, the string might be:
var teststring = "<!--X1-->Hi<!--X1-->there<!--X2-->";
I currently use this to get the matches:
var regex = new Regex("<!--X.-->");
var matches = regex.Matches(teststring);
The results of ...
Quick regex question (since i am horrible at it)
I have a field that can only have either:
XXXXXXXXXX or XXXXXX-XXXX where X is a real number.
Bonus if the regex works well with PHP's regex functions.
The Answer:
Here's the code from RoBorg's answer, for those interested.
if(!preg_match("/^\d{6}-?\d{4}$/", $var))
{
// The entry...
Hi All,
I am using a regular expression to find out whether the user entered value is alpha numeric, allowing some special characters.
I am using the following code which works fine:
CREATE OR REPLACE PROCEDURE Validate_Inputstring (input_String IN VARCHAR2) AS
BEGIN
IF REGEXP_LIKE(input_String,'^[A-Z0-9a-z,+-?@]*$') THEN
DB...
I'm trying to remove unused spans (i.e. those with no attribute) from HTML files, having already cleaned up all the attributes I didn't want with other regular expressions.
I'm having a problem with my regex not picking the correct pair of start and end tags to remove.
my $a = 'a <span>b <span style="color:red;">c</span> d</span>e';
$a...
I'm a little surprised that there isn't some information on this on the web, and I keep finding that the problem is a little stickier than I thought.
Here's the rules:
You are starting with delimited/escaped data to split into an array.
The delimiter is one arbitrary character
The escape character is one arbitrary character
Both the d...
I am looking for a regex to match all HTML tags, except <p> and </p> that includes the tag content. I am developing in ColdFusion.
There was an earlier post about matching tags except <p> and </p>, but I need to grab everything between the tags as well. For instance, the following should match in their entirety:
<a href="http://www.goo...
Having trouble figuring this out and feeling quite stupid...
I have many urls like this /imagebuilder-ptop.asp?imgCode=166 all I need is a regex that will match /imagebuilder-(ANTHING WHATSOEVER)
If is it /imagebuilder-lkd fa;lsdfh adhf alkdfhdfh I want to match it...anything.
...
I want to match this url /Real_estate_Listing_Detail.asp?PropID=245 with the ability to EXCEPT PropID numbers...
In other words,
Match /Real_estate_Listing_Detail.asp?PropID=ANY NUMBER HERE, except, 286,289,290,180
Thanks in advance... this shouldnt be as hard as I make it...
This is for a wordpress plugin, so a single line experss...
I came up with: ([^"]*["][^"]*["][^"]*)*
It works in all cases except against the empty string. I thought it would work because the last star matches the previous token zero or more times.
Any ideas?
Also if there's a much better way of doing this please let me know and explain it in detail.
The solution must be a regex as the place ...
I'm getting some html data from remote server and before displaying it in the UI of application i need to make some changes, i.e. delete counters, replace links, etc. Removing some tag with contents and changing specific link is not a big deal, but when it comes to some advanced processing, i have some problems.There is a need to replace...
I'm trying to make a regexp that will match numbers, excluding numbers that are part of other words or numbers inside certain html tags. The part for matching numbers works well but I can't figure out how to find the numbers inside the html.
Current code:
//number regexp part
var prefix = '\\b()';//for future use
var baseNumber = '((\\...
Hello all,
I am hoping the regular expression experts can tell me why this is going wrong:
This regex:
$pattern = '/(?<percent>[0-9]{1,3}\.[0-9]{1,2})% of (?<filesize>.+) at/';
Should match this sort of string:
[download] 87.1% of 4.40M at 107.90k/s ETA 00:05
[download] 89.0% of 4.40M at 107.88k/s ETA 00:04
[download] 91.4% of 4....
i am trying to validate a date in c# in the format "yyyy/mm/dd". is it even possible (using regex) to validate that there aren't 30 days in february?
...
an 20 - 24 char long alphanumeric string with no spaces and no symbols that has at least 2 digits
AAAAAAAAAAAAAAAAAAAA - not valid
AAAAAA0AAAAAAAAA0AAA - valid
AAAAAA01AAAAAAAAA0AAA - valid
AAAAAA0AAAAAAAAA0AAA@ - not valid
...
I have a regular expression that matches x OR y condition. Sometimes those matches overlap and I want to give preference to one of the conditions.
Here is my test case.
Regex:
X[^\w]*\>|\>[^\w]*X
Input:
Soup > X > Alphabet
Alphabet Soup > X
X > Alphabet Soup
Matches:
The first highlighted match (yellow) should be X...
Linux: I want to list all the files in a directory and within its subdirectories, except some strings. For that, I've been using a combination of find/grep/shell globbing. For instance, I want to list all files except those in the directories
./bin
./lib
./resources
I understand this can be done as shown in this question and this othe...
I'm building an app in python, and I need to get the URL of all links in one webpage. I already have a function that uses urllib to download the html file from the web, and transform it to a list of strings with readlines().
Currently I have this code that uses regex (I'm not very good at it) to search for links in every line:
for line...
If I had a div in HTML that had class="blah user_foo", whats the Match() regex to get the 'foo' bit?
...