How to find Regular Expressions in a Hash Map
Hi,
I Have a hash map with some keys. The Keys are like this(Java.util.regex, Javax.swing.table, javax.swing.text, Java.util.jar, Java.text etc). Suppose if the user gives the search pattern as "text", the o/p should be javax.swing.text and java.text.. How to do it using regular Expressions
// Sample code...
import java.util.regex.*;
public class TestRegex {
public static void main(String[] args) {
String test1 = "java.util.regex";
String test2 = "javax.swing.text";
String test3 = "java.util.jar";
String test4 = "java.text";
Pattern pat = Pattern.compile(".*text.*");
Matcher mt1 = pat.matcher(test1);
System.out.println("1> " +mt1.matches());
Matcher mt2 = pat.matcher(test2);
System.out.println("2> " +mt2.matches());
Matcher mt3 = pat.matcher(test3);
System.out.println("3> " +mt3.matches());
Matcher mt4 = pat.matcher(test4);
System.out.println("4> " +mt4.matches());
}
Similar Messages
-
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 use regular expression to find string
hi,
who know how to get all digits from the string "Alerts 4520 ( 227550 ) ( 98 Available )" by regular expression, thanks
br, AndrewLiu,
You can use RegEx as
d+
Whether you are using CL_ABAP_REGEX class then
report zars.
data: regex type ref to cl_abap_regex,
matcher type ref to cl_abap_matcher,
match type c length 1.
create object regex exporting pattern = 'd+'
ignore_case = ''.
matcher = regex->create_matcher( text = 'Test123tes456' ).
match = matcher->match( ).
write match
You can find more details regarding REGEX and POSIX examples here
http://www.regular-expressions.info/tutorial.html
a® -
How to use regular expression to delete a character?
Hello,
I have a query,
select partition_name from dba_tab_partitions where table_owner='xxx'and num_rows <>0 and table_name = 'xxx';
P5
P6
P7
P12
P13
P14
P17
P18
P19
P20
P24
How can I use regular expression in above SQL query to get result without letter 'P', like..
5
6
7
12
13
14
17
18
19
20
24
thank youI find answer...
select regexp_replace(partition_name,'P','')
thanks anyway -
How to build regular expression
I am trying to build a regular expression that will search the following array of strings for the sequence 3.1
Read Modem Information:
Device Type .......................... 2
Serial Number ........................ 11437
Primary Phone Number ................. 1800...
Secondary Phone Number ............... 1800...
Modem Software ....................... BOOT.3.1 Jun 17 2004 17:02:26
Bracelet Software .................... 4.0
Validation Number .................... Default
Login Name ........................... Default
Login Password ....................... Default
Case Number .......................... Default
Primary Encryption Key ............... Default
Secondary Encryption Key ............. Default
Dialing Format ....................... True
Call In Format ....................... True
Modem Download Flag is Clear ......... True
SCRAM Download Flag is Clear ......... True
SCRAM Char Table Load Flag is Clear .. True
Download Inhibit ..................... True
Exiting Boot (8 sec) ................. Switching to operating memory.
Main Revision ........................ SLCP.3.1 Jun 17 2004 17:02:46
Reset ................................ Complete
This is my first real foray into regular expressions and so I am lost trying to understand the help file.
Thanks!
Tay
Message Edited by slipstick on 09-25-2008 09:34 AMI think the OP was puzzled about how to form a RE.
For the specific case or how to find the exact string "3.1", and to not match anything else, the RE is "3\.1"
Why?
For the most part, a RE search string is an exact character match. However things change when certain "special characters" are included in the search string. The RE help message says what they are, but the descriptions can be a bit daunting at first.
As a first example of special characters, the RE of "." (The single character fullstop) will match ANY single character. Thus a RE of "3.1" will match "3.1", "301", "3Z1", but not "31" or 3aa1".
Another special character is "*". It modifies the match to allow zero or more of the preceeding bit. So "3.*1" matches "3", followed by any number of any character (including no characters), followed by "1". so it will match "31", "301", "3ABC51", "31111111"
The action of a special character is cancelled by preceeding it with a backslash. So in the example above "3\.1" matches ONLY the string "3.1"
The best way to discover exactly how RE's work is to try some out. Make a VI containing Match Pattern, and suitable controls and indicators. Work through the examples and see how they operate. Now try your own! -
How to use regular expressions to generate test data ?
Hi
Someone can help me on what I have to do in order to create test data with regular expressions ?
For example, I want to introduce a random telephone number (XXX-XXXX) in the phone number Form Field, I want to create the phone number using regular expressions in order to test different values in each playback of the script.
I don't want to use VB or vbscript in e-tester, I'm just trying to do this with e-load nav editor and e-load
Thanks a lotHi and thanks for your answer!, it's a great trick ^_^
I'm doing a research on how to improve the execution speed of the scripts in e-load, so actually I'm trying to avoid the use of databanks and VB code also.
I was expecting that maybe e-load, e-load nav editor or e-tester can automatically generate test data via Regular Expressions. Someone Knows if this is possible ?
Also can anyone tell me what the option "Automatically Generated (complex)" means ? I think that this will help me a lot
*you can find this option in e-load Nav Editor when you select a parameter in the tree view, then go to the "type" listbox in the properties pane, there you will find this option and some more options like :"Databanked variable", "Custom Dynamic Value", "Function".. etc.
Thanks again -
Help Finding Regular Expressions
Does Java have regular expressions? Where can I find them in the API?
Thanks!You can find them in the package java.util.regex (from version 1.4).
If you don't have that version, there is a GNU regular expression package available.
Søren Bak -
Hi,
I have a file that contains this format (separated by ;(semicolon) ):
user id;user name;email address;password;integer;list of integer(separated by ,(comma))
below is the example data :
abc;Abc;[email protected];password1;1;1,2
def;Def;[email protected];password;2;1,2,3
ghi;Ghi;[email protected];password;2;1
my question is how to verify the valid input for each row using regular expression..? TQ@Op. Doing a correct validation of e-mailaddresses
is very hard using regular expressions (doingbasic
validation is however easy)
http://www.regular-expressions.info/email.html
I like the RFC 822 compliant regexp :) -
How to use regular expression replace for this special characters?
hi,
I need to replace the below string, but i couldnt able to do if we use the special charaters '+', '$' . can anyone suggest a way to do this?
select REGEXP_REPLACE('jan + feb 2008','jan + feb 2008', 'feb',1,0,'i') from dual
anwers should be :- febyou should use escape character \.
the regular expression will look like as follows:
select REGEXP_REPLACE('jan + feb 2008','jan \+ feb 2008', 'feb',1,0,'i') from dual
hope this is what you needed.
cheers,
Davide -
How to use regular expression in editor?
I tried to add some text to all line in selected text in editor
ie .
x:= x+1 ; change to x:=x+1; log_something;
y:= y-1; -> y:= y-1 ; log_something;
and so on.
Then
1. select some text in editor
2.pressed Ctrl-R
3.in "text to search for" I put "^\(.*\)$"
4.in "replace with" I put "\1 log_something;
5.check "Regular expressions"
6. check "Selected text only"
I got "The search text "^\(.*\)$" was not found."
What am I doing wrong?Thanks. But now editor wants to replace whole text, not only selected by me, regardless of <<check "Selected text only" >>
Update: if I pick "scope: all" instead of "prompted" it shows popup "text not found" but replaces text as requested.
Message was edited by: user4879976 -
How to add regular expression in viewobject bind variables
Hi,
Am using java class to set the adf bind variables
vm.setWhereClause("FIRST_NAME = :fname");
vm.defineNamedWhereClauseParam("fname", null, null);
vm.setNamedWhereClauseParam("fname","Alana");
It works fine and it returns Alana
But what i want is to set a regular expression where it returns all the names that are starting with A.
I tried with this.
vm.setNamedWhereClauseParam("fname","A*");
also
vm.setNamedWhereClauseParam("fname","A%");
but both didn work.
Please help.
Thanks,
HariPerfect... Thanks Arun.
I tried including last name too. i.e when either of the one matches (first name or last name)
vm.setWhereClause("upper(FIRST_NAME) LIKE upper(:fname||'%')");
vm.defineNamedWhereClauseParam("fname", null, null);
vm.setNamedWhereClauseParam("fname","A");
vm.setWhereClause("upper(LAST_NAME) LIKE upper(:lname||'%')");
vm.defineNamedWhereClauseParam("lname", null, null);
vm.setNamedWhereClauseParam("lname","A");
But i guess we should not give it like this as it doesnt seem to work.
Hari -
How to display regular expression text
I cannot seem to get the text of a regular expression to display in a text input. The regex is defined as:
Bindable]
private var myRegExp:RegExp=/^.*(?=.{10,32})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[.!@#$%*^&()+]).*$/;
In my form, I want to display the actual expression. The code I am using to do so is:
<mx:FormItem label="regExpLabel">
<mx:TextInput id="regExpTextInput" text="{myRegExp}" />
</mx:FormItem>
When I run the app, the data displayed in the regExpTextInput filed is /^.*(?=.{10,32})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[.!@#$%*^&()+]).*$/
What I want to display is only the regular expression, not including the slashes required by Flex at the beginning and end of the string. The data I want displayed is ^.*(?=.{10,32})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[.!@#$%*^&()+]).*$
I tried changing my variable type to String and leaving out the beginning and ending slashes, but that did not work either. Any thoughts?
Thanks!Hi, I am unable to understand your requirement properly but here is one demo of the using regular expression. In this application I am allowing only those character to be enter in the Textbox which are taken as the valid filename. Hope this will help you.
I think In your requirement first of all you have to take it as string type. And the second is that use \\ before every special character if you are writing it in the script. As I have done. Pls let me know if you
Have any issue with the code below.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
[Bindable]
private var regExpForFile : String
= "0-9A-Za-z\\&\\`\\~\\!\\@\\#\\$\\%\\^\\(\\)\\-\\_\\=\\+\\]\\}\[\\'\\;\\,\\.\\{ ";
]]>
</mx:Script>
<mx:VBox horizontalAlign="center" width="350">
<mx:Label text="Enter File Name"/>
<mx:TextInput id="fileName" width="170" height="20" restrict="{regExpForFile}"/>
</mx:VBox>
</mx:Application>
with Regards,
Shardul Singh Bartwal -
How to find what are the support-teams map with particular componant type
hi experts,
i am new in solution manager.. My requirement is when creating the support message in crmd_order t-code i have to give the componant type in transaction data after that in fast entry screen i have to assign support team for that componant type .. here i have to give only valid support team which are map with particular componant type .. when save the support message here i have to check that support team is map with that particular componant type (i.e that support team is belong to that componant type ) .. thats what i have to do in abap development .. so how to find the what are all the support teams mapped with particular componant type .. whether it is stored in any table or ?.. Please give solutions ..
Regards,
Kumar..Hi Kumaresan-
I'm not sure I fully understand your requirement but I will try to help out. If you are trying to determine / associate the relevant support team according to which component they are responsible for, this might help.
The determination of the support team is maintained by configuring rule 13200137 in transaction PFAC_RESPO.
Click on the Responsibilities Tab
Create your responsibility based on your support team requirements
Assign the appropriate Support Team, this data will be taken from the settings you have maintained when creating your org chart in ppoma_crm
Highlight a responsibility and click Change
In this table you will see an entry for SAP Component, this is where you identify which support team will be determined based on component -
How to write regular expression to find desired string piece
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...
MennanHi, Mennan,
You can nest REGEXP_SUBSTR withing REGEXP_REPLACE to get the n-th occurrence, like this:
SELECT lst
, REGEXP_REPLACE ( REGEXP_SUBSTR ( lst
, 'name:[^#]*#lastname'
, 1
, n
, 'name:(.*)#lastname'
, '\1'
) AS nm If the pattern occurs fewer than n times, the expression above returns NULL. -
How to use regular expression using pattern and match concept for this scenario?
Hi Guys,
I have a string "We have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle"
I need to replace the numbers based on the below condition.
if more then 5, replace with many
if less then 5, replace with a few
if it is 1, replace with "only one"
below is my code, I am missing the equating part to replace the numbers could any one of you please help me out fixing this.
private static String REGEX="(\\d+)";
private static String INPUT="We have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle";
//String pattern= "(.*)(\\d+)(.*)";
private static String REPLACE = "replace with many";
public static void main(String[] args) {
// Create a Pattern object
Pattern r = Pattern.compile(REGEX);
// Now create matcher object.
Matcher m = r.matcher(INPUT);
//replace the value 7 by the replace string
//How to equate the (\\d+) greater than a number and use it the below code.
INPUT = m.replaceAll(REPLACE);
//Print the final Result;
System.out.println(INPUT);
Thanks and Regards,Hi,
Try the following which makes use of "appendReplacement" instead with the "start" and "end" methods to locate and check the searched "regExp" string before dynamically setting the "replace" string:
String regExp = "\\d+";
String input = "We have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle";
String replace;
Pattern p = Pattern.compile(regExp);
// get a matcher object
Matcher m = p.matcher(input);
StringBuffer sb = new StringBuffer();
while (m.find()) {
Integer x = Integer.valueOf(input.substring(m.start(), m.end()));
replace = (x >= 5) ? "many" : (x == 1) ? "only one" : "few";
m.appendReplacement(sb, replace);
m.appendTail(sb);
System.out.println(sb.toString());
HTH.
Regards,
Rajen
P.S: Please mark the post as answered/helpful if it resolves your issue for the benefit of all community members.
Maybe you are looking for
-
Where do I find the UI Scaling option in Photoshop CC 2014?
I have a Companion Cintiq running Win 8.1..I am a new PS user..After searching for an answer to the tiny and unreadable text and icons on my screen and not being able to enlarge them (no, the display fix inside Windows doesn't do it), I basically fou
-
Dear all, Can the ScaleBasis in the Control data of T/code MEKE be changed from B Value scale to C Quantity scale? Mine is greyed out. Thank you.
-
Producer consummer loop and timing loop
Hi, I have to acquire 32 signals and record each signals. I would like to acquire my signals at a sample rate of 100kHz. But I tried with a different sample read and I have always an error of overwritten. In my producer loop I read and display all si
-
How do I repost a webpage that has been saved as an Archive?
I created a webpage, posted it to my .mac account, then took it down. Now I want to go back and repost the same page. I saved the webpage as a Safari archive. Can anyone help me with this? Thanks, Robin
-
Unable to use sqlloader to load large data into a varchar2 column..plz.help
Hi, Currently the column in the database is a varchar2(4000) coulmn that stores data in the form of xml and data that has many carrriage returns. Current I am trying to archive this column value and later truncate the data in this column. I was able