Regular Expression for finding Latin characters
i have a table "t" with values in column "text" like
"Āniki"
"Ąvatar"
How can I find them using a regular expression?
The real goal is to replace them with their ASCII equivalent.
Ā = A
Č = C
Ĥ = H
etc....
You can set any range in the ascii table by using the expression 'X-Y' in the pattern. It works for symbols too, but you need to find out whether the desired characters you're interested actually form a contiguous range.
You can run the below query to check the ascii table:
SELECT LEVEL ascii_val, chr(LEVEL) chr_column FROM dual CONNECT BY LEVEL < 256;Then you can pick and choose your ranges and verify them as in the following query:
WITH t AS
(SELECT LEVEL ascii_val, chr(LEVEL) chr_column FROM dual CONNECT BY LEVEL < 256)
SELECT ascii_val, chr_column FROM t WHERE regexp_like(chr_column, '[^A-Za-z0-9!-/]');In the example above I chose a range from the ascii 33 ('!') to 47 ('/'), described by the portion '!-/' in the pattern.
To add another range just concatenate it after the slash symbol.
Additionally, for example, if you want to add a range including the symbols:
ASCII CHR
58 :
59 ;
60 <
61 =
62 >
63 ?You can set it up like this instead if you feel it's more easily readable:
WITH t AS
(SELECT LEVEL ascii_val, chr(LEVEL) chr_column FROM dual CONNECT BY LEVEL < 256)
SELECT ascii_val, chr_column
FROM t
WHERE regexp_like(chr_column, '[^A-Za-z0-9' ||
chr(33) || '-' || chr(47) ||
chr(58) || '-' || chr(63) ||
']');You need to test this though, as the docs state the behaviour may vary depending on your NLS_SORT settings, by using linguistic ranges rather than byte values. For my settings it seems to work, not sure about everywhere else.
Note: In the POSIX standard, a range includes all collation elements between the start and end of the range in the linguistic definition of the current locale. Thus, ranges are linguistic rather than byte values ranges; the semantics of the range expression are independent of character set. In Oracle Database, the linguistic range is determined by the NLS_SORT initialization parameter.http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_regexp.htm
and
http://download.oracle.com/docs/cd/E11882_01/server.112/e10729/ch5lingsort.htm
You can check your NLS_SORT by querying the userenv:
SQL> select sys_context('USERENV', 'NLS_SORT') from dual;
SYS_CONTEXT('USERENV','NLS_SOR
WEST_EUROPEAN
SQL> If it returns BINARY you need not worry about it.
Otherwise you can check the particular sorting your NLS_SORT will use here:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10729/applocaledata.htm#NLSPG593
Usually symbols are not affected by it as you can see there (my case too for the "west_european" value), but other elements in a string can be affected.
Regards,
Sitja.
Edited by: fsitja on Mar 18, 2010 1:51 PM
Similar Messages
-
Issues regular expression for "find all" feature
Hi,
I am currently working on a website in dreamweaver that
contains about 2000 pages. I know some of these pages are missing a
div called id="breadcrumb". I have tried to find a way to search in
the "entire current local website" for pages that do not contain
any div with the id="breadcrumb". However, it does not seem to
work, I tried using the {n} syntax as {0} but it doesn't return
anything I expect, which is pages that do not contain
id="breadcrumb".
Thanks for your help.
Loic> I am currently working on a website in dreamweaver that
contains about
> 2000
> pages. I know some of these pages are missing a div
called
> id="breadcrumb". I
> have tried to find a way to search in the "entire
current local website"
> for
> pages that do not contain any div with the
id="breadcrumb". However, it
> does
> not seem to work, I tried using the {n} syntax as {0}
but it doesn't
> return
> anything I expect, which is pages that do not contain
id="breadcrumb".
An option:
Is this div normally next to another unique HTML element on
the page that is
in all pages? Like this:
<div id="xyz">
<div id="breadcrumb">
If so, you could to a find for:
<div id="xyz">
and replace with:
<div id="xyz">
<div id="breadcrumb">
Then, since the pages that already had the breadcrumb div
would now have
both, you do a second search and replace to remove the
duplicates:
find:
<div id="breadcrumb">
<div id="breadcrumb">
replace:
<div id="breadcrumb">
Of course, you'd still have to worry about the closing
</div> tag and that
might get tricky.
Ultimately, though, a site with 2000 pages really is a likely
candidate for
a migration into a CMS instead of manually having to maintain
individual
HTML files like this.
-Darrel -
String Regular Expression for uncommon characters
Hi,
I am trying to get text out of HTML file for which I am using EditorKit and Document classes. After I obtain the text, the text (String) contains some characters like �. This character looks like a with French style acute accent . My problem is how to use regular expression to find and replace (replaceAll method) these unwanted characters.
Is there a regular expression pattern for such characters?
Thanks!
Rahul.hrm I would recommend looking at the specific patterns,
a simplified site would be here http://www.p3m.org/wiki?regex
as a refernce . If you dont know regular expression, use
http://www.perl.com/doc/manual/html/pod/perlre.html
The only way I could think of constructing the regex is to use the \s and add the characters you want in that regex :s you could look into regex look ahead and look behind methods... -
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" -
Regular Expression for PathName???
Anyone have a "ready to go" regular expression for detecting a pathname?
for example I need to detect the following:
myfile.txt
./myfile.txt
../my-file.ini
/home/my-home/myFile.foo
etc.
Now, in a perfect world, it could also do Windows (or ANY OS for that matter) pathnames (though this is not terrbibly important for my case at least).
TIA,
/mimport java.util.regex.*;
* @author Ian Schneider
public class FileRegex {
static Pattern pattern;
/** Creates a new instance of FileRegex */
public FileRegex() {
public Pattern getPattern() {
if (pattern == null) {
pattern = Pattern.compile("([\\/]?(\\w+|\\.|\\.\\.)[\\/])*(\\w+)\\.?(\\w+)?");
return pattern;
public String[] parts(String path) {
Matcher m = getPattern().matcher(path);
if (m.find()) {
return new String[] { m.group(1),m.group(3),m.group(4) };
return null;
public boolean matches(String path) {
return getPattern().matcher(path).matches();
public static final void main(String[] args) throws Exception {
FileRegex regex = new FileRegex();
String[] files = {
"myfile.txt",
"../myfile.txt",
"./myfile.txt",
"/a/b/c/myfile.txt",
"/a/../myfile.txt",
"myfile"
for (int i = 0, ii = files.length; i < ii; i++) {
System.out.println( files[i] + " match " + regex.matches(files));
String[] pieces = regex.parts(files[i]);
if (pieces != null)
System.out.println(" path : " + pieces[0] + " file : " + pieces[1] + " ext : " + pieces[2]);
I will leave it to you as an excercise to add support for spaces in path names, different separator characters, etc.. -
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
-
Unable To Use Regular Expression To Find Function Names
Hi,
I am trying to create a regular expression to find function and procedure names without the static designation and the parameter list. Sample source document:
static function test
static function test(i,j)
function test
function test(i,j)
static procedure test
static procedure test(i,j)
procedure test
procedure test(i,j)
For each of the above samples, I would like only the word "test" to be found.
ThanksI suggest starting with this expression:
^\s*(static\s+)?(function|procedure)\s+(?<NAME>\w+)
Programmatically, the name can be extracted from the group called “NAME”.
The expression can be improved. -
How to write regular expression to find desired string piece *duplicate*
Hi All,
Suppose that i have following string piece:
name:ali#lastname:kemal#name:mehmet#lastname:cemalI need
ali
mehmetI use following statement
SQL> select lst, regexp_replace(lst,'(name:)(.*)(lastname)(.*)','\2',1,1) nm from (
2 select 'name:ali#lastname:kemal#name:mehmet#lastname:cemal' as lst from dual
3 );
LST NM
name:ali#lastname:kemal#name:mehmet#lastname:cemal ali#lastname:kemal#name:mehmet#
SQL> But it does not return names correctly. When i change 5th parameter(occurence) of regexp_replace built-in function(e.g. 1,2), i may get ali and mehmet respectiveley.
Any ideas about regexp?
Note : I can use PL/SQL instr/substr for this manner; but i do not want to use them. I need regexp.
Regards...
Mennan
Edited by: mennan on Jul 4, 2010 9:53 PM
thread was posted twice due to chrome refresfment. Please ignore the thread and reply to How to write regular expression to find desired string pieceThe approach is to do cartesian join to a 'number' table returning number of records equal to number of names in the string.I have hardcoded 2 but you can use regexp_count to get the number of occurrences of the pattern in the string and then use level <=regexp_count(..... .
See below for the approach
with cte as(
select
'name:ali#lastname:kemal#name:mehmet#lastname:cemal' col ,level lev
from dual connect by level <=2)
select substr(regexp_substr('#'||col,'#name:\w+',1,lev),7)
from cte
/ -
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).
-
Regular Expression for /, \, #, -, &
Hi,
Can anybody tell me the regular expression for provided characters.
Code is preferable.
Thanks in advance."[-/\\\\#&']"
-
What is the regular expression for the end of a story?
Forgive me if this is wrong forum for asking this, but I'm trying to use the Find command using GREP and I need to know the regular expression for the end of a story. (Or, the last character of a story.) Thanks in advance.
I'd try search for .\z (that's a dot in front) which ought to find the very last character in the story, and replace with $0 and your additional text.
You know you can use a keyboard shortcut to move your cursor to the end of any story, right? Ctrl + End on Windows, Cmd + End, I think, on Mac. Unless you want to do this to every single story in the document, I would think you might be just as well off to put your text on the clipboard, put the cursor in the story and hit the key combo followed by Ctrl/Cmd + V to paste. -
Regular Expression for multiple emails
Hi! I have a jsp page that has an inputTextArea so the user can enter multiple email addresses. In the backing bean (after they submit) I tokenize thru it and add email addresses to an arraylist. I want to validate that they are correct format before adding to arraylist, but how do I do that in the backing bean? All regular expression examples I have seen are in jsp page and javascript. Any sample code / suggestions would be greatly appreciated - as I have not had much experience with regular expressions. Thanks!
Hi,
this could be a solution for your problem; I've created two regular expressions to find valid email- and http-addresses in fulltext or xml-text fields ;-)
HTTP:
(\\s|>|^)(?!(@|/|\\.))(http://|https://|ftp://|sftp://|www\\.)([A-Za-z0-9_-]{2,}\\.)+[A-Za-z]{2,4}[:]?(/|\\?|\\&|\\;|\\%|=|\\.|\\#|_|-|[A-Za-z0-9])*(?!(@))(?<=([A-Za-z0-9=]+))(\\s|\\W|_|<|$)
eMail:
(\\s|>|^)(?!(:|www\\.|\\.))[A-Za-z0-9_.-]+@([A-Za-z0-9_-]+\\.)+[A-Za-z]{2,4}(\\s|\\W|_|<|$)
sincerely
Hans Georg Filipp -
Regular Expression For Dreamweaver
I still haven't had the time to really become a professional when it comes to regular expressions, and sadly I am in need of one an finding it difficult to wrap my head around.
In a text file I have hundreds of instances like the following:
{Click here to visit my website}{http://www.adobe.com/}
I need a regular expression for Dreamweaver that I can run within the "Find and Replace" window to switch the order of the above elements to:
{http://www.adobe.com/}{Click here to visit my website}
Can anyone provide some guidance? I'm coming up short due to my lack of experience with regular expressions.
Thank you in advance!So you have a string that starts { and goes until the first }. Then you have another string exactly the same. And you want to swap them. I'm not making any assumption that the second one has to look like a URL (that's a whole other minefield, but perhaps you could do something simple like it must start with http).
You don't specify how your text file is divided up, have you got this as a complete line to itself, or is it just a huge block of text? Preferably as individual lines.
I don't have Dreamweaver, but this worked for me in Notepad++
Find: ^{(.*?)}{(.*?)}$
Replace with: {\2}{\1}
My file looked like this:
{Click here to visit my website}{http://www.adobe.com/}
{some other site}{http://www.example.com/foo}
And doing a Replace All ended up like this:
{http://www.adobe.com/}{Click here to visit my website}
{http://www.example.com/foo}{some other site} -
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 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
Maybe you are looking for
-
How to Download to iMovie on MacBook Air from Sony HandyCam Model DCR HC21
I have a Macbook Air, with USB and Thunderbolt ports. I'd like to download to iMovie from my Sony HandyCam DCR HC21. I have a Firewire cable, which I used to download to my old Macbook Pro. Is there an adapter? Do I have to download to the old Pr
-
Itunes Library Size / Unlimited Online Storage
Hi - I have a question regarding Itunes library size. I have a couple of movies, some music and even TV series on my itunes library and its slowly getting bigger and bigger. Is there a certain limit for the itunes library size? And if so, does apple
-
Working with remote application
Hello everyone ! I installed the remote app on my iPad 2 to work with Apple TV3. And the application does not recognize the apple TV3. But the application detects the iTunes on my computer. What should I do to app detects the apple tv? Thank you very
-
My Client have a Exchange 2010 Organization with Single Domain Single Forest. They were using Internal CA Certificate and a TLS Cert. As a POC we are doing a POC for Exchange 2010 Hybrid Office 365 Environment. For this 3rd Party CA is Mandatory and
-
Do I need mobile me to use find my iPad
I want to use find my iPad but I found out that you can't subscribe to mobile me any more, what do I do?