0

I have been attempting to fix my regex but I cannot.I want capture group 3 to contain all letters and white space between the digit 3 and capture group 2.

.*([A-Z]{3}|[A-Z]{3})+\s+([0-9]{4}|[0-9]{4}\w)\s{2}(.*?)\d 

My regex properly gets this but it has no line breaks.

ACG 3141  Intermediate Financial Accounting II  3 hrs 

My regex cant get

ACG 3501  Financial Accounting for Governmental and 
Nonprofit Organizations  
3 hrs 

TAX 4001  Taxation of Business Entities and 
Transactions  
3 hrs 

I cant figure out how to use (.*?)\d to go to the next digit ignoring the line breaks in capture group 3.

OneU
  • 85
  • 6
  • I'd guess you need the `s` modifier so the `.` extends to new lines..(not a java'r so that might be wrong) – chris85 Jan 05 '17 at 22:53
  • ...so `s` modifier didn't work? https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#DOTALL `In dotall mode, the expression . matches any character, including a line terminator. By default this expression does not match line terminators.` – chris85 Jan 05 '17 at 23:00
  • 1
    Dotall modifier will do the job, see [this demo](https://regex101.com/r/72yGrr/1). – Wiktor Stribiżew Jan 05 '17 at 23:06
  • @chris85 I mean I am trying it in http://regexr.com/ but its not working.Thanks for responding! – OneU Jan 05 '17 at 23:06
  • 1
    Show your usage that isn't working.. – chris85 Jan 05 '17 at 23:07
  • Tip: you probably don't want to capture the stuff until the next digit, so use `(?:.*?)` instead of `(.*?)` to make it a non-capturing group. – Maarten Bodewes Jan 05 '17 at 23:11

0 Answers0