The code below gives me this mysterious error, and i cannot fathom it. I am new to regular expressions and so am consequently stumped. The regular expression should be validating any international phone number.
Any help would be much appreciated.
function validate_phone($phone)
{
$phoneregexp ="^(\+[1-9][0-9]*(\([0-9]*\)|-[0-9]*-))?[0...
I'm not sure if Jeff coined it but it's the joke/saying that people who say "oh, I know I'll use regular expressions!" now have two problems. I've always taken this to mean that people use regular expressions in very inappropriate contexts.
However, under what circumstances are regular expressions really the best answer? What problems ...
One of my developers has started using RegexBuddy for help in interpreting legacy code, which is a usage I fully understand and support. What concerns me is using a regex tool for writing new code. I have actually discouraged its use for new code in my team. Two quotes come to mind:
Some people, when confronted with a
problem, t...
Please don't answer the obvious, but what are the limit signs that tell us a problem should not be solved using reg exprs.
For example: Why is a complete email validation too complex for a regular expression?
...
I am working with some input that is in the possible forms
$1,200
20 cents/ inch
$10
Is there a way to parse these to numbers in VB? Also printing these numbers?
EDIT: Regular expressions would be great.
EDIT: VB 6 in particular
...
Hi,
I make a request to an xml web service, and get back a response. This response, being a stream, is then saved to a string. The problem is, the response is full of tags, CDATA, etc (as you would expect). There is no line breaking either, as to be expected.
I want to take this string, which represents an xml document, and strip it of...
I'm building up a library of filters for a validation class in PHP, some of them using regular expressions. I have a lot of filters in mind, but I also don't want to potentially miss any. What do you most often use regular expressions to check? What are some of the not-so-common things that you've had to check that would still be useful ...
I need to match (case insensitive) "abcd" and an optional trademark symbol
Regex: "/abcd(™)?/gi"
See example:
<?php
preg_match("/abcd(™)?/gi","AbCd™ U9+",$matches);
print_r($matches);?>
When I run this $matches isn't populated with anything... not even created as an empty array. Any ideas?
Thanks.
...
I've run into a strange situation that seems to involve long text overflowing. I'm using fn_pcre_replace (from the xp_pcre extended stored procedure) on an nvarchar(max) column, and when I replace with more characters than were there originally, it returns NULL if the original string was over 8000 characters long.
For example, this
Se...
Hi,
Please could someone help me with writing a regex expression to replace 0044 token which will be at the start of the string with a 0. Please note that I do not want to replace all 0044 tokens with 0, only those that appear at the start of the string.
Thanks a lot
...
I have this problem:
The text "ABCD\r\nEFGHJ" loaded from a file is matched with java regex "EFGH". Matcher object of course says start of the matched string is in position 6. The matcher counts \r \n as two positions.
I put the original text in a AWT TextArea Component and then call select(6,10) to highlight the area which was matched...
I have a comma separated list of strings like the one below.
a,b ,c ,d, , , , ,e, f,g,h .
I want to write a regular expression that will replace the empty values i.e., strings that contain only white spaces to 'NA'. So the result should be
a,b ,c ,d,NA,NA,NA,NA,e, f,g,h .
I tried using ",\s+," to search but it skips the ...
That was an interview question that I was unable to answer:
How to check that a string is a palindrome using regular expressions?
p.s. There is already a question "How to check if the given string is palindrome?" and it gives a lot of answers in different languages, but no answer that uses regular expressions.
...
I need to replace some 2- and 3-digit numbers with the same number plus 10000. So
Photo.123.aspx
needs to become
Photo.10123.aspx
and also
Photo.12.aspx
needs to become
Photo.10012.aspx
I know that in .NET I can delegate the replacement to a function and just add 10000 to the number, but I'd rather stick to garden-variety Reg...
I'm using the Infragistics WinForms UltaGrid control and I'm setting the RegexPattern property. How do I get the grid cell I'm setting the RegEx for to actually use that pattern to restrict entry? Or am I misunderstanding how the RegexPattern property works.
Jeff
...
Hi,
I'm trying to come up with a Java regex that will match a filename only if it has a valid extension. For example it should match "foo.bar" and "foo.b", but neither "foo." nor "foo".
I've written the following test program
public static void main(String[] args) {
Pattern fileExtensionPattern = Pattern.compile("\\.\\w+\\z");
bo...
Hi all,
First post, so here goes. I'm writing a script that does intelligent search and replace on a file tree. Essentially, the script gets each file's contents into a buffer string and performs a match with a pre-defined pattern, in this case the pattern is /^[^\r\n]*(vendor)[^\r\n]*$/im. The pattern should find any case-insensitive f...
Hi.
I need to use sed to convert all occurences of ##XXX## to ${XXX}. X could be any alphabetic character or '_'. I know that I need to use something like:
's/##/\${/g'
But of course that won't properly, as it will convert ##FOO## to ${FOO${
Any takers?
- Don
...
My applications frequently use Regex for input validation.
Most of the Regex values that I need are pretty common (email address, basic types, etc).
What is a good place to both learn about Regex creation and find common Regex patterns?
...
I'm probably doing this all wrong. I have a text file full of data and I want to match and replace patterns of "item" and "catalog number" that are in the file. But the order of each element in the file is very important, so I want to match/replace starting from the top of the file and then work my way down.
The code snippet below actua...