Phone number Regular expression Help
Hi,
I am trying to validate phone number using regular expression.
The format shoud be either of the two given below. It should not
accept phone number of any other format other than the once given below.
I tried out the following regular expression
pn.matches("[\p{+}][0-9]+ ")
but it accepts alphabets too(which is wrong).
How do i check if the phone number is of the following format(OR condition).
0401234567
+358501234567
Any help would be kindly appriciated.
Thanks
Sanam
There will probably be much more constraints on you phone numbers, but here's a start:String[] numbers = {"0401234567", // should be ok
"040123456", // wrong, one number too little
"+358501234567", // should be ok
"+3585012345670", // wrong, one number too much
"+35850123456"}; // wrong, one number too little
String regex = "\\+[0-9]{12}"+ // a + sign, followed by 12 numbers
"|"+ // OR
"0[0-9]{9}"; // a zero, followed by 9 numbers
for(String n : numbers) {
System.out.println("Is "+n+" valid? "+n.matches(regex));
}
Similar Messages
-
Phone Number - Regular Expression
I'm trying to validate a phone number using regular expressions.
My validation appears as the following:
IF REGEXP_LIKE ( :P10_PHONE, '^\(?[[:digit:]]{3}\)?[-. ]?[[:digit:]]{3}[-. ]?[[:digit:]]{4}$' ) THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
The problem I noticed is that it returned true even if I typed in a phone number like this:
(555 123-4567
Is there a way to tell it that if one parenthesis is there that the other one should be there as well? Or should I just do an instr if the regexp_like returns true and double-check it myself?
Thanks,
ChadYou can use the OR operator (|)...
'^(\([[:digit:]]{3}\)|[[:digit:]]{3})[-. ]?[[:digit:]]{3}[-. ]?[[:digit:]]{4}$'
Rodney -
Is there a phone number for Nokia help? I would like to speak with a live person to get help with my problem
Check HERE for your local Nokia Care ..
-
Was installing new ios 7 and it asked for acct and password. it did not like and said it would email a new password. no email received. can not figure the Apple support screens to find a phone number to call. help.
No need for alarm. There are several folks a day posting like threads. Most folks know these phishing attempts for what they are and merely delete with prejudice.
To the bottom line... if you wish - and I am sure Apple will take notice - you should FORWARD the email to [email protected] and delete.
CCC -
Is there a phone number for customer help?
Is there a phone number for customer help?
Nitan15479421 what Adobe software or service are you seeking assistance with? You can find the contact options for your registered software titles and membership at Contact Customer Care. Please make sure to log in under the Adobe ID tied to your membership/registered software titles.
-
I need help writting a regular expression that will match the following strings:
1+1,1+(1+1),((1+1)+(1+1)),1+(1+(1+1)). Basically one that will match an arithmetic expression (operands limited to 1's and operators to '+' sign) with or without correctly matched parentheses. Have'nt had much luck so far. Any input will help. thanksokay, you asked for it:
[1+()]+
it will only match those string but it will tell you nothing about syntactically correct expressions. This is because these types of expression are not "regular" and cannot be properly parsed using regular expressions. -
My IMessage is sending from my email, and I am recieving
Messages thru my email. I have tried to fix this by going to Settings > messaging > recieved at> and my phone number pops up along with my email. It will let me click on my email, but my phone number is greyed out and I can't click on it.i have also tried caller id, which still didn't fix the problem.
Trying to kill two birds with one stone, my phone also says that I have no storage left. I literally have 3 apps installed on my phone. Facebook, Twitter, and instagram. I only have 52 photos, 0 videos, and about 115 songs. I know for a fact that I shouldn't be out of storage, because I have friends with the same iPhone 4, that have 400 pictures, a thousand songs, and page after page of apps. I want to know what is taking up all of the storage, and what can I do to get rid of it. Thank you in advanceSorry G23 - I like birds ;)
I suggest you start another thread as I don't know the answer to that one but this might help:
Go to settings - general - usage - Her e you might find some data hogs
Good luck -
I'm using a RegExp class (http://www.jurjans.lv/flash/RegExp.html) to do some regular expression in AS2. But I'm not very good at it.
var str:String="What if there are other variables, such as possible <a class='gloss' href='asfunction:_root.handle, confounding variables'><b>confounding variables</b></a> which could explain at least some of the relationship between the two variables? Here <a href='' target='_blank'>is another link</a>.\n<a class='gloss' href='asfunction:_root.handle, confounding variables'>confounded variables</a>"
var reg1:RegExp = new RegExp("<a.*gloss.*href=[\'\"]?([^\\\'\">]+)>+(.*</a>)", "ig");
var obj:Object = reg1.exec(str);
while (obj != null) {
for(var a in obj){
if(!isNaN(a)){
trace(a+": "+obj[a]);
trace(newline);
obj = reg1.exec(str);
And this traces:
2: <b>confounding variables</b></a>
1: asfunction:_root.handle, confounding variables'
0: <a class='gloss' href='asfunction:_root.handle, confounding variables'><b>confounding variables</b></a>
2: confounded variables</a>
1: asfunction:_root.handle, confounding variables'
0: <a class='gloss' href='asfunction:_root.handle, confounding variables'>confounded variables</a>
I'm trying to get the href and the "friendly link" part of the anchor tag (but only for anchors that have a class of gloss).
As you can see I'm almost there, but I'm getting the extra </a> and the extra ' on the two examples. I tried putting the ) before the </a> but that just broke it. (Of course that could be because this class doesn't work properly, but I'm guessing that isn't the case.)
Anybody really good with regular expressions who can help me out?Looks like there is a "greedy" bug with the () in that AS2 implementation.
I also have a problem the expression matching not the next occurance of the closing </a> but the final one.
Anybody have any ideas of other ways to do this? -
Regular Expressions help needed.
Hi,
I have lines like
<div id="contentSub"> 26
/*]]>*/</style> 27
<ul> 30
Dylan is gay 36
var wgNamespaceNumber = 0; 41You see every line is contained a string plus some white spaces then plus a number.
How to retrieve the strings?
Such that becomes
<div id="contentSub">
/*]]>*/</style>
<ul>
Dylan is gay
var wgNamespaceNumber = 0; And also get the number by a regular expression
26
27
30
36
41ThanksI believe that
"^(.*)\\s+(\\d+)$"would do the trick. Pick the two groups out from the Matcher. -
Regular Expression help required
{color:#000000}Hi....
I am having a product table in oracle with products like CZS20T and CZSS30T and so on....
But for printing on the invoice we need only the product name without the micron thickness like CZS and CZSS{color}{color:#000000}
I tried regular expression with....."select regexp_substr('CZSS20T','([[:digit:]]{2})') from dual"
{color}
and the result was "20"*...*
But I cant figure out how to use regular expression to get only the product name.
Maybe there is another way without using Regular exp...
Please help....regexp_substr (prod, '[[:alpha:]]*')and an example:
SQL> with x as
2 ( select 'CZS20T' prod from dual union all
3 select 'CZSS30T' from dual union all
4 select 'A10CSD' from dual
5 )
6 select prod
7 , regexp_substr (prod, '[[:alpha:]]*')
8 from x
9 ;
PROD REGEXP_SUBSTR(PROD,'[[:ALPHA
CZS20T CZS
CZSS30T CZSS
A10CSD A
SQL> Edited by: Alex Nuijten on Jan 27, 2009 8:52 AM -
I haven't used regular expressions before, and I'm having trouble finding a regular expression to extract a string subset between two markers.
The string;
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
ERRORS 6
Info I want line 1
Info I want line 2
Info I want line 3
Info I want line 4
Info I want line 5
Info I want line 6
END_ERRORS
From the string above (this is read from a text file) I'm trying to extract the string subset between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number 1 through 32, and the number of lines I want to extract will correspond with this number. I can supply this number from a calling VI if necessary.
My current solution, which works but is not very elegant;
(1) uses Match Regular Expression to the return the string after matching ERRORS 6
(2) uses Match Regular Expression returning all characters before match END_ERRORS of the string returned by (1)
Is there a way this can be accomplished using 1 Match Regular Expression? If so could anyone suggest how, together with an explanation of how the regular expression given works.
Many thanks
Alan
Solved!
Go to Solution.I used a character class to catch any word or whitespace characters. Putting this inside parentheses makes a submatch that you can get by expanding the Match Regular Expression node. The \d finds digits and the two *s repeat the previous term. So, \d* will find the '6', as well as '123456'.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice -
Regular Expression Help Please?
Hi
I'm trying to get my head round regular expressions in find
and replace,
it's a slow process for me!
I have this -
<a
href="
http://www.forms.mydomainname.com/cgi-bin/urltracker/tracker.pl?site=http://www.website-ad dress.com"
and I'm trying to change it to this -
<a
href="
http://www.forms.mydomainname.com/cgi-bin/urltracker/tracker.pl?site=http://www.website-ad dress.com&email="
I was trying first of all with a *.*, but couldn't work out
how to tell it
where the code ends?
They are hundred of pages like this, all with different
website-addresses.
After I have changed all the pages to the new code, I then
will need to copy
and paste an different email address to the end of each line,
to each page.
Unless anyone knows a way of automating that?
Hope someone can point me in the right direction?
Many thanks, Craig.Hi David
Many thanks for all that and the detailed descriptions.
I will be working through it all again tomorrow, so will put
your info to
the test! lol
As for partially building the email addresses, I think that
would be too
much,
as the emails are all over the place, some have their own
domain, other use
hotmail, Yahoo etc.
Some even have they own domain for their website and a free
one for the
email address.
They are all Hotels, B&B' & Cottages etc.
Hopefully all your hard work will help me a step closer to
understanding it
all.
Many thanks again,
Craig.
"David Stiller" <[email protected]> wrote in
message
news:[email protected]...
> Craig,
>
>> You do have that correct David, thanks.
>
> Okay.
Regex is as much an "exact science" as it is an "art
> form" -- which isn't to say I'm a regex artist; I just
love the
> technology -- but I mention this because I made the
following assumption
> in order to keep the pattern relatively simple: your
href values are all
> quoted in either single or double quotes. Such as, for
example, the
> following sample HTML ...
>
> <body>
> <a
> href="
http://www.forms.mydomainname.com/cgi-bin/urltracker/tracker.pl?site=www.sample.com">asfd< /a>
> <a
> href='
http://www.forms.mydomainname.com/cgi-bin/urltracker/tracker.pl?site=www.example.net'></a>
> <a
> href="
http://www.forms.mydomainname.com/cgi-bin/urltracker/tracker.pl?site=www.company.com"></a>
> </body>
>
> In the Find field, enter this pattern ...
>
> (tracker\.pl\?site=.*?)(["'])
>
> ... and in the Replace field, enter this pattern ...
>
> $1&email=ADDRESS$2
>
> Then carefully use your Find Next and Replace buttons to
step through
> your code. The above will add &email=ADDRESS to your
HTML in all the
> right places. I chose that because ADDRESS is easy to
select by double
> clicking, which should facilitate your replacing it.
>
>
> Let's step through the patterns.
>
> (tracker\.pl\?site=[^"']*?)(["'])
>
> This looks for the phrase "tracker.pl?site=" (without
quotes) followed
> immediately by a "non-greedy" match of any character
that isn't a single
> or double quotation mark, followed immediately by either
a single or
> double quotation mark. I took , which I took to be a
safe, short "hook"
> into the string we need. I split this pattern into two
sections, grouped
> by parentheses. This allows us to refer to the first
part of the match
> (everything but the closing quotation mark) as group 1,
and the second
> part (the closing quotatin mark) as group 2. This is
like storying values
> with your calculator's M (memory) button.
>
> $1&email=ADDRESS$2
>
> Here, we refer to group 1 and follow it with the phrase
> "&email=ADDRESS" (without quotes), followed again by
group 2.
>
> Now, in theory, we could use the domain name of each
unique site to at
> least partially build the email address. That would get
you even closer
> to your goal. To do so, I'd need even more detail from
you, such as the
> kinds of domains you have (how many sub domains are
probable, etc.).
>
>
> David
> stiller (at) quip (dot) net
> Dev essays:
http://www.quip.net/blog/
> "Luck is the residue of good design."
> -
PL/SQL Regular Expression help.
A'ight, I'm braindead today and cannot figure this out. I have data that can be in following formats:
format 1: '123 (A XXX)'
format 2: '123 (A (XXX) Z)'
format 3: '123 (A (XXX) Z)(B (YYY) Z)'
Looking for a regular expression that will parse data and return following:
result 1: '(A XXX)'
result 2: '(A (XXX) Z)'
result 3: '(A (XXX) Z)'
Thanks for your help.SQL>l
1 with t as (
2 select '123 (A XXX)' col from dual union all
3 select '123 (A (XXX) Z)' from dual union all
4 select '123 (A (XXX ) Z)' from dual union all
5 select '123 (A (XXX) Z )' from dual union all
6 select '123 (A (XXX) Z)(B (YYY) Z)' from dual union all
7 select '123 (A (XXX) Z )(B (YYY) Z)' from dual union all
8 select '123 (A (XXX) Z) (B (YYY) Z)' from dual union all
9 select '123 (A (XXX) Z ) (B (YYY) Z)' from dual
10 )
11 select col, length(col), instr(col, '(') sp, instr(col, ')')-1 ep,
12 substr( col , instr(col, '(') , instr(col, ')')-1) new_col
13* from t
SQL>/
COL LENGTH(COL) SP EP NEW_COL
============================ ================ ================ ================ ==============================
123 (A XXX) 11 5 10 (A XXX)
123 (A (XXX) Z) 15 5 11 (A (XXX) Z)
123 (A (XXX ) Z) 16 5 12 (A (XXX ) Z)
123 (A (XXX) Z ) 16 5 11 (A (XXX) Z
123 (A (XXX) Z)(B (YYY) Z) 26 5 11 (A (XXX) Z)
123 (A (XXX) Z )(B (YYY) Z) 27 5 11 (A (XXX) Z
123 (A (XXX) Z) (B (YYY) Z) 27 5 11 (A (XXX) Z)
123 (A (XXX) Z ) (B (YYY) Z) 28 5 11 (A (XXX) Z
8 rows selected. -
Regular expression help to solve sys_refcursor for a record
In reference to my thread Question on sys_refcursor with record type , I thought it can be solved differently. That is:
I have a string like '8:1706,1194,1817~1:1217,1613,1215,1250'
I need to do some manipulation using regular expressions and acheive some thing like
select * from <table> where
c1 in (8,1)
and c2 in (1706,1194,1817,1217,1613,1215,1250);Is it possible using regular expressions in a single select statement?Hi,
Clearance 6`- 8`` wrote:
Your understanding is absolutely correct. But unfortunately it did not work Frank.
SQL> SELECT COUNT (*)
2 FROM (SELECT sp.*
3 FROM spml sp, spml_assignment spag
4 WHERE sp.spml_id = spag.spml_id
5 AND spag.class_of_svc_id = 8
6 AND spag.service_type_id IN (1706, 1194, 1817)
7 AND spag.carrier_id = 4445
8 AND NVL (spag.haulage_type_id, -1) = NVL (NULL, -1)
9 AND spag.effdate = TO_DATE ('01/01/2000', 'mm/dd/yyyy')
10 AND spag.unit_id = 5
11 AND sales_org_id = 1
12 UNION ALL
13 SELECT sp.*
14 FROM spml sp, spml_assignment spag
15 WHERE sp.spml_id = spag.spml_id
16 AND spag.class_of_svc_id = 1
17 AND spag.service_type_id IN (1217, 1613, 1215, 1250)
18 AND spag.carrier_id = 4445
19 AND NVL (spag.haulage_type_id, -1) = NVL (NULL, -1)
20 AND spag.effdate = TO_DATE ('01/01/2000', 'mm/dd/yyyy')
21 AND spag.unit_id = 5
22 AND sales_org_id = 1);
COUNT(*)
88
SQL> SELECT COUNT (*)
2 FROM spml sp, spml_assignment spag
3 WHERE sp.spml_id = spag.spml_id
4 AND spag.carrier_id = 4445
5 AND NVL (spag.haulage_type_id, -1) = NVL (NULL, -1)
6 AND spag.effdate = TO_DATE ('01/01/2000', 'mm/dd/yyyy')
7 AND spag.unit_id = 5
8 AND sales_org_id = 1
9 AND REGEXP_LIKE ('8:1706,1194,1817~1:1217,1613,1215,1250',
10 '(^|~)' || spag.class_of_svc_id || ':'
11 )
12 AND REGEXP_LIKE ('8:1706,1194,1817~1:1217,1613,1215,1250',
13 '(:|,)' || spag.service_type_id || '(,|$)'
14 );
COUNT(*)
140
SQL> Edited by: Clearance 6`- 8`` on Aug 11, 2009 8:04 PMJust serving what you ordered!
Originally, you said you were looking for something that produced the same result as
where c1 in (8, 1)
and c2 in (1706, 1194, 1817, 1217, 1613, 1215, 1250)that is, any of the c1s could be paired with any of the c2s.
Now it looks like what you want is
where ( c1 = 8
and c2 IN (1706, 1194, 1817)
or ( c1 = 1
and c2 IN (1217, 1613, 1215, 1250)
)that is, c1=8 and c2=1250 is no good; neither is c1=1 and c2=1706.
In that case, try
WHERE REGEXP_LIKE ( s
, '(^|~)' || c1
|| ':([0-9]+,)*'
|| c2
|| '(,|~|$)'
) -
Regular Expressions Help in Dreamweaver
Hi i am using Dreamweaver CS3, i am creating more than 100 HTML files every couple of days and need to use the regular Expressions Feature in the Find and Replace box but couldn't find or generate the expression i am looking For, i want to Replace every images name to be same as it's htm file name across all htm Files.
Ex : cieg.htm
<tr>
<td colspan="2"><table id="Table_04" width="850" height="88" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="Viva/XXXthefilenameXXX_38.gif" width="213" height="88"></td>
<td><img src="Viva/XXXthefilenameXXX_39.gif" width="212" height="88"></td>
<td><img src="Viva/XXXthefilenameXXX_40.gif" width="213" height="88"></td>
<td><img src="Viva/XXXthefilenameXXX_41.gif" width="212" height="88"></td>
</tr>
</table></td>
</tr>
and replace it to be:
<tr>
<td colspan="2"><table id="Table_04" width="850" height="88" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="Viva/cieg_38.gif" width="213" height="88"></td>
<td><img src="Viva/cieg_39.gif" width="212" height="88"></td>
<td><img src="Viva/cieg_40.gif" width="213" height="88"></td>
<td><img src="Viva/cieg_41.gif" width="212" height="88"></td>
</tr>
</table></td>
</tr>
and same as another htm file named zsac.htm
Any one knows a way to do it???
RegardsDreamweaver's Find and Replace can't use the filename automatically. You would need to do it separately for each page. However, the following regular expression should speed up the process on individual pages:
Find in: Current Document
Search: Source Code
Find:
(<img src="Viva/)[\w]+(\d{2}.gif")
Replace
$1cieg_$2
In other words, you need to add "cieg" or the name of the file between $1 and _$2.
[Edited by DP to correct error in first sentence. DW cannot use the filename automatically.]
Maybe you are looking for
-
How do you change the appearance of iCal in Lion?
The reason I am asking as I am not fond of the "suede leather western-look" & hoped there were other options to choose from. I would think there would be but I can not seem to find info. HELP!
-
Trying to understand how to set up Match
I have tried this twice and gotten the same result: - load all tracks in iTunes on the main computer - turn on Match, let it do it's thing (it says success) - sync iPod with cable to the main computer with Match turned OFF Then, when I turn on Match
-
Computer sees ipod, but..
my computer will see the ipod when i plug it in, but itunes wont see it or update it
-
Re: what happens to the online number after expiry...
I recently got a skype number. I spread it out to my friends. Now I also get calls from somebody I don't know - apparently this number have been used. What should I do? Also, I don't want my contacts to (mistakenly) call some other person should I de
-
Whatever happened to previews.db in Lightroom 5 Catalog Previews.lrdata?
In earlier versions of Lightroom, there used to be a file called previews.db inside a directory called "Lightroom 5 Catalog Previews.lrdata" , but in Lightroom 5.7, I see that "Lightroom 5 Catalog Previews.lrdata" has become a file (no longer a direc