0

I am having the following data in a text file:

 proc sort data=oneplan.cust_duplicates(dbindex=yes) out=mibatch.cust_duplicates;
    from oneplan.fsa_authorised_agencies (dbindex=yes) 
    set oneplan.fsa_agency_permissions(where=(regulated_activity in ('103','106','107','108')));
    set oneplan.customer_flags(where=(flag_id in(54,14,34)));
    from oneplan.document_history (dbindex=yes) 
    set oneplan.product_references;
  proc sort data=oneplan.fast_track_log(where=(upcase(business_entry)="INCOME VERIFICATION FAST TRACKED"))   out=fast_track_log;
    set oneplan.product_characteristics(rename=(value=filler)where=(characteristic_type="OFFS" ));
    set oneplan.mtg_offset_benefits (where=(modified_date between &extractdate and &batchcutoff) 
      from oneplan.mtg_payment_options a;
    from oneplan.acc_retention_risk acr;
    from oneplan.acc_retention_risk_hist acr;
    from oneplan.account_repay_veh rv;
    from oneplan.repay_vehicle_map rvm;
    from oneplan.frozen_accounts as fa left join mibatch.accounts as a

Now i need to fetch the part from each line which starts with oneplan. and ends with a space.

Also if the line has two oneplan. then each must be extracted separately.

Example: agtut oneplan.m htyutu oneplan.j hgyut

i need the output as: oneplan.m and oneplan.j

kindly give me suggestions in doing this please...

1
  • Is this homework? Should have a homework tag if so. Commented Mar 13, 2011 at 17:33

3 Answers 3

3

You could use a regex like:

String text = ....
String regex = "(oneplan\\.\\w)\\w+\\s+";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);
while(matcher.find()) {
   System.out.println(matcher.group(1));
}

Will print the results:

oneplan.f
oneplan.d
oneplan.m
oneplan.m
oneplan.a
oneplan.a
oneplan.a
oneplan.r
oneplan.f

If you instead want the entire word you can use matcher.group() in combination with the regex:

"oneplan\\.\\w+\\s+"
Sign up to request clarification or add additional context in comments.

1 Comment

And, take a look at this post if you'd like to know how to use regex : stackoverflow.com/questions/5291102/…
0

You can start with BufferedReader#readLine and String#startsWith String#endsWith.

Comments

0

Take a look at the various String.indexOf() and String.substring() methods.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.