Help me! Give me a Regular Expressions for Email and URL!
see title!
Thank you very much!
URL pattern:
String proto="(\\w+)";
String userPassAt=":(\\w+)(?::(\\w+))?@";
String host="([^\\s:/\\<>]+)";
String port=":(\\d+)\\b";
String file="/([^\\s:?]*)"; //backslash not included
String query="\\?(\\S*)"; //'?' not included
String urlPattern=proto + ":" + possibly("//") + possibly(userPassAt) + host + possibly(port) + possibly(file + possibly(query));
static String possibly(String s){
return "(?:"+s+")?";
Group numbers:
protocol = 1
user = 2
pass = 3
host = 4
port = 5
file = 6
query = 7
Regards
Similar Messages
-
Hi all,
Can anyone help me to create a regular expression validation for email id? I have tried many combinations from internet regarding this validation, but everyone fails on APEX, although it runs fine in .NET or JAVA.
Expressions i tried was "^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$", i want to validate email address such as "[email protected]". Can anyone help me in this regard?
With Regards,
Sunil BhatiaHello Sunil,
>> Can anyone help me to create a regular expression validation for email id?
If you are talking about an email address, it’s not clear to me why you include the ‘http’ string in your regular expression. In any case, I’m using the following:
^[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]{1,}@[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]{1,}\.{1}[a-zA-Z]{2,4}$Regards,
Arie.
Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all. -
Regular expression for email address formats
I have the following regulare expression which I am using to validate email address format.
This allows addresses of the form
[email protected]
^[-a-zA-Z0-9._]+\@[-a-zA-Z0-9]+\.[-a-zA-Z0-9]+\.[-a-zA-Z0-9]+$
And of course this allows addresses of the form
[email protected]
^[-a-zA-Z0-9._]+\@[-a-zA-Z0-9]+\.[-a-zA-Z0-9]+$
What I'm looking for is something which will allow both.This way
'^[-a-zA-Z0-9._]+\@[-a-zA-Z0-9.]+$' would allow both. :-)
with test_data as
( select '[email protected]' as val from dual union all
select '[email protected]' as val from dual union all
select 'no#good' as val from dual
select
val ,
case
when regexp_like( val, '^[-a-zA-Z0-9._]+\@[-a-zA-Z0-9.]+$' ) then 'Y'
else 'N'
end
as good
from test_data ;
VAL G
[email protected] Y
[email protected] Y
no#good NBut then again, it would also allow "[email protected]" and "[email protected]" too. So I suspect you don't really want something that simply allows your two cases to pass validation. If you want to allow only those two cases then try something like this.
with test_data as
( select '[email protected]' as val from dual union all
select '[email protected]' as val from dual union all
select '[email protected]' as val from dual union all
select '[email protected]' as val from dual union all
select 'no#good' as val from dual
select
val ,
case
when
regexp_like
( val
, '^[-a-zA-Z0-9._]+\@[-a-zA-Z0-9]+\.[-a-zA-Z0-9]+(\.[-a-zA-Z0-9]+)?$'
) then 'Y'
else 'N'
end
as good
from test_data ;
VAL G
[email protected] Y
[email protected] Y
[email protected] N
[email protected] N
no#good N--
Joe Fuda
SQL Snippets
Message was edited by SnippetyJoe - added clarification. -
How to form a regular expression for matching the xml tag?
hi i wanted to find the and match the xml tag for that i required to write the regex.
for exmple i have a string[] str={"<data>abc</data>"};
i want this string has to be splitted like this <data>, abc and </data>. so that i can read the splitted string value.
the above is for a small excercise but the tagname and value can be of combination of chars/digits/spl symbols like wise.
so please help me to write the regular expression for the above requirementyour suggestion is most appreciable if u can give the startup like how to do this. which parser is to be used and stuff like that
-
Very challenging Regular Expression(for me atleast) ..HELP
This is a complex situation for me and i would really appreciate if you could help me out with the regular expression that meets my condition
Scenerio:
Lets assume i am reading a file that has only numbers or integers in it. Now i need to read each line by line and print an error message if a condition is met.
Consition is:
If there is a number >= 50 in with at least 5 zeros in front or 5 zeros back of it
print"error encountered"
Example 1
12454540000000050584
Print "error" because there are atlease 5 consecutive zeros in front of 50
Example 2
24546744500005800000000
Print "Error" because there are atleast 5 consecutive zeros behind 80( which is greater than 50)
Example 3
24546744500005800000000068
Print "error" message because there are atleast 5 consecutive zeros behing 58 BUT 68 does not meet the condition because there are only 4 consecutive zeros infront of it because rest of the zeros are already associated with 58 and cannot be recounted. Zeros are counted in a chunk of five and a chunk could only be counted once.
Please resond to this thread if more clarification is needed.
Appreciate your help. You guys ROCK.Hiklior wrote:
This is a complex situation for me and i would really appreciate if you could help me out with the regular expression that meets my condition
Scenerio:
Lets assume i am reading a file that has only numbers or integers in it. Now i need to read each line by line and print an error message if a condition is met.
Consition is:
If there is a number >= 50 in with at least 5 zeros in front or 5 zeros back of it
print"error encountered"
Example 1
12454540000000050584
Print "error" because there are atlease 5 consecutive zeros in front of 50
Example 2
24546744500005800000000
Print "Error" because there are atleast 5 consecutive zeros behind 80( which is greater than 50)
Example 3
24546744500005800000000068
Print "error" message because there are atleast 5 consecutive zeros behing 58 BUT 68 does not meet the condition because there are only 4 consecutive zeros infront of it because rest of the zeros are already associated with 58 and cannot be recounted. Zeros are counted in a chunk of five and a chunk could only be counted once.
That last sentence makes me think that maybe regex is not the way to go here. Well that and what seem to math operations.
I don't think I understand the more than 50 stuff.
So here is I think what I do understand
- more than 5 zeroes in front of a 5 is bad
- I think once you have a pattern of zeros and then a 5 everything trailing the five is part of the zeroes until the END of the next set of zeros
Is that right? -
Request some help, over procedure's performance uses regular expressions for its functinality
Hi All,
Below is the procedure, having functionalities of populating two tables. For first table, its a simple insertion process but for second table, we need to break the soruce record as per business requirement and then insert into the table. [Have used regular expressions for that]
Procedure works fine but it takes around 23 mins for processing 1mm of rows.
Since this procedure would be used, parallely by different ETL processes, so append hint is not recommended.
Is there any ways to improve its performance, or any suggestion if my approach is not optimized? Thanks for all help in advance.
CREATE OR REPLACE PROCEDURE SONARDBO.PRC_PROCESS_EXCEPTIONS_LOGS_TT
P_PROCESS_ID IN NUMBER,
P_FEED_ID IN NUMBER,
P_TABLE_NAME IN VARCHAR2,
P_FEED_RECORD IN VARCHAR2,
P_EXCEPTION_RECORD IN VARCHAR2
IS
PRAGMA AUTONOMOUS_TRANSACTION;
V_EXCEPTION_LOG_ID EXCEPTION_LOG.EXCEPTION_LOG_ID%TYPE;
BEGIN
V_EXCEPTION_LOG_ID :=EXCEPTION_LOG_SEQ.NEXTVAL;
INSERT INTO SONARDBO.EXCEPTION_LOG
EXCEPTION_LOG_ID, PROCESS_DATE, PROCESS_ID,EXCEPTION_CODE,FEED_ID,SP_NAME
,ATTRIBUTE_NAME,TABLE_NAME,EXCEPTION_RECORD
,DATA_STRUCTURE
,CREATED_BY,CREATED_TS
VALUES
( V_EXCEPTION_LOG_ID
,TRUNC(SYSDATE)
,P_PROCESS_ID
,'N/A'
,P_FEED_ID
,NULL
,NULL
,P_TABLE_NAME
,P_FEED_RECORD
,NULL
,USER
,SYSDATE
INSERT INTO EXCEPTION_ATTR_LOG
EXCEPTION_ATTR_ID,EXCEPTION_LOG_ID,EXCEPTION_CODE,ATTRIBUTE_NAME,SP_NAME,TABLE_NAME,CREATED_BY,CREATED_TS,ATTRIBUTE_VALUE
SELECT
EXCEPTION_ATTR_LOG_SEQ.NEXTVAL EXCEPTION_ATTR_ID
,V_EXCEPTION_LOG_ID EXCEPTION_LOG_ID
,REGEXP_SUBSTR(str,'[^|]*',1,1) EXCEPTION_CODE
,REGEXP_SUBSTR(str,'[^|]+',1,2) ATTRIBUTE_NAME
,'N/A' SP_NAME
,p_table_name
,USER
,SYSDATE
,REGEXP_SUBSTR(str,'[^|]+',1,3) ATTRIBUTE_VALUE
FROM
SELECT
REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
FROM
DUAL t1 CROSS JOIN
TABLE
CAST
MULTISET
SELECT LEVEL
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
AS SYS.odciNumberList
) t2
WHERE REGEXP_SUBSTR(str,'[^|]*',1,1) IS NOT NULL
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RAISE;
END;
Many Thanks,
ArpitRegex's are known to be CPU intensive specially when dealing with large number of rows.
If you have to reduce the processing time, you need to tune the Select statements.
One suggested change could be to change the following query
SELECT
REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
FROM
DUAL t1 CROSS JOIN
TABLE
CAST
MULTISET
SELECT LEVEL
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
AS SYS.odciNumberList
) t2
to
SELECT REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,level) str
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
Before looking for any performance benefit, you need to ensure that this does not change your output.
How many substrings are you expecting in the P_EXCEPTION_RECORD? If less than 5, it will be better to opt for SUBSTR and INSTR combination as it might work well with the number of records you are working with. Only trouble is, you will have to write different SUBSTR and INSTR statements for each column to be fetched.
How are you calling this procedure? Is it not possible to work with Collections? Delimited strings are not a very good option as it requires splitting of the data every time you need to refer to. -
hi i got a new airport express for christmas and i set it up as per instructions ,i even give a static ip and wpa2 security ..the problem is is when i come to want to use it it says its not on my network and a orange triangle shows .when i reboot it works..then if i leave it a while and try iy agian its disapeared of my network...i have a bt hub 3 ....any help please ..im not sure if itsa faulty express
I really don't have an answer for that one. I guess that while trying to get things working correctly, I would use the most basic monitor I had which in your case would be the Eizon using the Thunderbolt port and adaptor.
When you boot into Safe Mode the startup is quite slow, but you should get the Apple logo and then the spinning gear below it (release the SHIFT key when it appears.) Then after a little more time you should see a gray progress bar appear below the spinning gear. When that disappears the computer will startup to a login screen. -
Regular Expressions for converting HTML to Structured Plain Text
I'm writing a PL/SQL function that will convert HTML to plain text, but still preserve some of the formatting/line breaks. One of my challenges is in writing a regular expression to capture the text blocks while ignoring the markup. I'm trying to write an expression that will grab all of the text between start/end tags, but discard the tags. For example, to find all of the text between a start/end paragraph, I want to do something like:
REGEXP_REPLACE('<p style="text-align:center;">This is the body of the paragraph</p>', '<p.*>(.*)</p>', '\1||v_crlf' )
where \1 returns the contents of the paragraph and v_crlf (declared earlier in the function) inserts a line break. I know there are more general expressions that will remove all tags, but I want to specifically identify the tags so I can process them appropriately. This way I can easily convert HTML to plain text for email and reporting without having to keep two versions around. Any help would be greatly appreciated. Once I get this worked out, I will repost with the function code for others to use. Thanks.
Edited by: jritschel on Oct 26, 2010 9:58 AMHere's a function I wrote for an app. I'm not making in promises on it's accuracy as the app was just a proof of concept and never made it to production.
function strip_html( p_clob in clob )
return clob
is
l_out clob;
l_test number := 0;
l_max_loops constant number := 20;
i pls_integer := 0;
begin
l_out := regexp_replace(p_clob,'<br>|<br />',chr(13)||chr(10),1,0,'imn');
l_out := regexp_replace(l_out,'<p>',chr(13)||chr(10),1,0,'imn');
l_out := replace(l_out,'<li>',chr(13)||chr(10)||'*<li>');
l_out := regexp_replace(l_out,'<b>(.+?)</b>','*\1*',1,0,'imn');
l_out := regexp_replace(l_out,'<u>(.+?)</u>','_\1_',1,0,'imn');
loop
l_test := regexp_instr(l_out,'<([A-Z][A-Z0-9]*)[^>]*>.*?</\1>',1,1,0,'imn');
exit when l_test = 0 or i > l_max_loops;
l_out := regexp_replace(l_out,'<([A-Z][A-Z0-9]*)[^>]*>(.*?)</\1>','\2',1,0,'imn');
i := i + 1;
end loop;
return l_out;
end strip_html;{code}
The loop is there to handle nested HTML.
Tyler Muth
http://tylermuth.wordpress.com
"Applied Oracle Security: Developing Secure Database and Middleware Environments": http://sn.im/aos.book
Edited by: Tyler on Oct 26, 2010 10:03 AM -
Regular Expression for a Person's Name
Hi,
I am using the org.apache.regexp package and trying to find the regular expression for a person's name. It allows only the alphabetic string.
I tried [a-zA-Z]+. But this also accepts the thing like "BUSH88", which is not what I want...
Can anybody help me figure this out?
Thanks in advance,
TongHi,
I am using the org.apache.regexp package and trying to
find the regular expression for a person's name. It
allows only the alphabetic string.
I tried [a-zA-Z]+. But this also accepts the thing
like "BUSH88", which is not what I want...
Can anybody help me figure this out?
Thanks in advance,
Tongtry this:
^[a-zA-Z]+$
the ^ represents the start of the String and the $ represents the end.
So the expression is saying: "between the beginning and the end of the String there will only be alphbetical characters" -
How to write the regular expression for Square brackets?
Hi,
I want regular expression for the [] Square brackets.
I have tried to insert in the below code but the expression not validate the [] square brackets.
If anyone knows please help me how to write the regular expression for [] Square brackets.
private static final Pattern DESC_PATTERN = Pattern.compile("({1}[a-zA-Z])" +"([a-zA-Z0-9\\s.,_():}{/&#-]+)$");Thanks
RaghavSince square brackets are meta characters in regex they need to be escaped when they need to be used as regular characters so prefix them with \\ (the escape character).
-
Need a regular expression for the text field
Hi ,
I need a regular expression for a text filed.
if the value is alphanumeric then min 3 char shud be there
and if the value is numeric then no limit of chars in that field.[0-9].
Any help is appriciated...
thanks
bharathi.Try the following in the change event:
r=/^[a-z]{1,3}$|^\d+$/i;
if (!r.test(xfa.event.newText))
xfa.event.change="";
Kyle -
Regular expression for recognizing all tables in a sql statement
Hi all
I need a regular expression for recognizing all the tables bane in a geberic statement.
Unlikely i need a regular expression that manage also inner join .I 'm sorry but this matter is new for me and i cannot find any usefull help in the web.
RegardsIf you insist it should be something like:
"SELECT ([A-Z0-9_]+)[.][A-Z0-9_]+(,([A-Z0-9_]+)[.][A-Z0-9_]+)* FROM (([A-Z0-9_]+)[.][A-Z0-9_]+) INNER JOIN (([A-Z0-9_]+)[.][A-Z0-9_]+) ON .+" plus spaces etc... Yes it's for this kind of statements only.
But SQL parser is better because anyway you'll need to at least remove duplicates from founded names... -
Hi Everyone,
I need help with regular expression for following scenario .
If any of the DBCC command is run against sql server i want it to be captured . Something like if it starts with DBCC it should be captured .
For instance following is expression for
DBCC CheckDB : part="dbcc checkdb", rgxp="(\s|;|^)dbcc\scheckdb\s?\((((to[a-z0-9_\$\#\.\@])|(t[abcdefghijklmnpqrstuvwxyz0-9_\$\#\.\@])|([abcdefghijklmnopqrsuvwxyz]))[a-z0-9_\$\#\.\@]*)\s?\)(\s|;|$)"
But instead of writing expression for all DBCC commands is there any way to write a regular expression say if DBCC i want it to be captured .
Thanks
Suhas VallalaHi Suhas,
As Olaf said, regular expressions is not supported in SQL Server. To trace the DBCC event, you can use the SQL Sever Profiler, just tick the Security Audit--> Audit DBCC Event. You can set up a trace in the profiler by following the below tutorial.
SQL SERVER – Introduction to SQL Server 2008 Profiler
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Hi All,
What should be the regular expression for string MT940_UB_*.txt and MT940_MB_*.txt to be used as filename inSFTP sender channel in PI 7.31 ??
If any one has any idea on this please let me know.
Thanks
NehaHi All,
None of the file names suggested is working.
I have tried using - MT940_MB_*\.txt , MT940_MB_*.*txt , MT940*.txt
None of them is able to pick this filename - MT940_MB_20142204060823_1.txt
Currently I am using generic regular expression which picks all .txt files. - ([^\s]+(\.(txt))$)
Let me know ur suggestion on this.
Thanks
Neha Verma -
Using regular expressions for validation in i18n
Can we use regular expressions for validation of inputs in a java application taking care of i18N aspects too. Zip code for different locales are different. Can we use regular expressions to validate zipcode inputs from different locales
hi,
For that shall i have to create individual patterns for matching the inputs from different locales or a single pattern will do in the case of validating phone nos. around the world, zip codes etc. In case different patterns are required, programmer should have a konwledge of difference in patters for different locales.
regards
sdas
Maybe you are looking for
-
Hello! I'm using Bridge CS4 for image research projects. This is all fine and good for inputting info. However, others on the project don't have time to launch photoshop to look at every bit of metadata I'm inputting. They like print outs. Is there A
-
I am deploying my application components on Oracle RAC database, when i install my app component i will run a script which creates a user and tablespace on bot rac-nodes(node1 and node2) as database is clustered, the user are created on 2 nodes and t
-
My itunes creates duplicates in my iphone
Fisrt I purchased Anamanaguchi through my iphones's itunes. Then I created a ringtone using a song from that album. Then the original song keeps playing ringtone part. In my macbook, it plays full song, but in my iphone, it plays only ringtone part,
-
Global messages and inilne messages both are being displayed
Hi, I have a page index.xhtml in which i am including another page header.xhtml like this <ui:insert name="header"> <ui:include src="header.xhtml" /> </ui:insert> my header.xhtml is <?xml version="1.0" encoding="UTF-8"?> <!DO
-
Area of the parts != Area of the whole
My tables are polygon datasets stored in NAD83 (SRID=8265) and I have noticed that the sum of area calculations of a subdivided polygon do not equal the area of the original polygon. I created a simple test case to confirm the results. I created a sq