pth30041
(pth30041)
October 27, 2010, 7:12pm
1
Hi,
It’s been awhile but need to ask this question. I have a string that I would to use regex to perform search in that string.
String input:
This is a test from 12345.3345.mail@domain.com . Text1 text 2 text3.
In the input string, I would like to search for ‘@domain.com’ and I want it to provide the entire result as '[EMAIL=“12345.3345.mail@domain.com”]12345.3345.mail@domain.com ’[/EMAIL] Is there a function that I can use in my flow?
v_rock
(v_rock *)
October 28, 2010, 5:49am
2
Hi pthcincy,
U can get that function by using the flowservice named indexOf under wmpublic.pub.string:subString. For eg. Input text is test123@Mail.com
subString Inputs
instring → String input
beginIndex → point from where in the input string will be the substring will start
Endindex → end point of the INput string or End point of the Search string ur looking for
pth30041
(pth30041)
October 28, 2010, 6:11pm
3
V_Rock,
How does that work when you don’t know the beginIndex and Endindex? What if the input string is
1234.5678.mail@domain.com test1 test2 test3.
I want to search “@domain.com ” and I want the output to be “1234.5678.mail@domain.com ”
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String inputString = IDataUtil.getString( pipelineCursor, “inputString” );
String regexString = IDataUtil.getString( pipelineCursor, “regexString” );
pipelineCursor.destroy();
ArrayList x=new ArrayList();
Pattern pat;
Matcher mat;
pat=Pattern.compile(regexString);
mat=pat.matcher(inputString);
while(mat.find())
{
x.add(mat.group());
}
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “matchingwods”, x.toArray() );
pipelineCursor_1.destroy();
For input string provide String input:
for regex provide [^" "]+@domain.com
The problem is output will be list of objects not in string format.
ArnaudW
(ArnaudW)
October 29, 2010, 1:20pm
5
For input string provide String input:
for regex provide [^" "]+@domain.com
The problem is output will be list of objects not in string format.
There is also the service PSUtilities.regex:find in PSUtilities with the same inputs.
Suren
(Suren)
October 29, 2010, 3:41pm
6
If it is definitive that there is going to be only one email address present in the input string then this should work :
String domainString = mat.group().toString();
and you can get it as a string.