Regular expressions - result

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?

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

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.

There is also the service PSUtilities.regex:find in PSUtilities with the same inputs.

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.