
Jerred121
Members-
Posts
55 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Jerred121's Achievements

Member (2/5)
0
Reputation
-
I got it working though. I used strstr to parse the string a the line that I wanted and performed the preg_match on the parsed string. Less "elegant"than just one REGEX pattern, but it works.
-
problem is that i don't know how many lines to skip.
-
I want a pattern that will match every line after a particular line - the only constant that I can rely on is that if the header is there I know I want the follow lines. It doesn't matter if I end up getting more lines than I want because I'll only take the first however many I need. SURGICAL/MEDICAL HISTORY <--Header to indicate the beginning of my list HISTORY 1 <--line1 to be matched HISTORY 2 <--line2 to be matched HISTORY 3 <--line3 to be matched . . I'm not posting a real sample of the text because it shouldn't matter - the pattern must be flexible and for other particular reasons. I just always have such an issue with lines in regex. Here is what I have: $ptn = "/SURGICAL\/MEDICAL HISTORY\s*(^(.+)$)+/m"; I need all of the matched lines in separated in an array: Array ( [0] => Array ( [0] => SURGICAL/MEDICAL HISTORY HISTORY 1 HISTORY 2 ) [1] => Array ( [0] => HISTORY 1 [1] => HISTORY 2 ) ) Thanks for any suggestions
-
Sorry, looks like I forgot to include a sample of the data: temp: 35.20c / 95.36f - axillary temp: 35.20c / 95.36f temp: 35.20c / 95.36f - oral As you can see the " - method" is optional.
-
So just when I think i'm getting the hang of REGEX, I realize that I suck still and I can't get this simple extraction to work... I want to extract the temp and the method separately: Array ( [0] => Array ( [0] => temp: 35.20c / 95.36f - axillary [1] => temp: 35.20c / 95.36f [2] => temp: 35.20c / 95.36f - oral ) [1] => Array ( [0] => 35.20c / 95.36f [1] => 35.20c / 95.36f [2] => 35.20c / 95.36f ) [2] => Array ( [0] => axillary [1] => [2] => oral ) I'm even embarrassed to post my sorry pattern, but I'm sure you guys can figure it out. As always, thank you!
-
First you need to escape your slashes ie: </b> should be <\/b>, i'm not sure but it probably wouldn't hurt to escape your <>'s also
-
I'm not nearly as good with REGEX as some of the REGEX ninjas on here, but this worked for me when trying to remove the semicolon lines: $ptn = "/[^;](?:.*)\n/"; preg_match_all($ptn, $str, $match); foreach($match[0] as $key => $value){ echo "$value <br />"; // do whatever you want with the lines that don't start with ; }
-
Your good and that was quick! thank you so much, the people on this forum are awesome!
-
need an example of the text file.
-
Here is the code with the subject ($str) and the pattern that I started with - I've tried a lot of variations but I can't get it grab all of the variables that I need, so I figured I'd post what I started with: $str = " Intervention: Airway-Intubation of Existing Tracheostomy Stoma successful Intervention: CPR-Start Compressions only without Ventilation Intervention: CPR-Start Compressions only without Ventilation - 12:30 AM successful Intervention: Activation-Fire Rehabilitation Specialty Service/Response Team not successful Intervention: Blood Glucose Analysis - 2:30 PM not successful Intervention: Venous Access-Femoral Line successful"; $ptn = "/Intervention: *(.+) *-+? *(([0-2]*[0-9]+:[0-5]+[0-9] *(??:A|P)M)))* *((?:not )?successful)*/"; preg_match_all($ptn, $str, $CZprocedures); echo"<pre>"; print_r($CZprocedures); echo"</pre"; Here is the output from above: Array ( [0] => Array ( [0] => Intervention: Airway- [1] => Intervention: CPR- [2] => Intervention: CPR-Start Compressions only without Ventilation - 12:30 AM successful [3] => Intervention: Activation- [4] => Intervention: Blood Glucose Analysis - 2:30 PM not successful [5] => Intervention: Venous Access- ) [1] => Array ( [0] => Airway [1] => CPR [2] => CPR-Start Compressions only without Ventilation [3] => Activation [4] => Blood Glucose Analysis [5] => Venous Access ) [2] => Array ( [0] => [1] => [2] => 12:30 AM [3] => [4] => 2:30 PM [5] => ) [3] => Array ( [0] => [1] => [2] => 12:30 AM [3] => [4] => 2:30 PM [5] => ) [4] => Array ( [0] => [1] => [2] => successful [3] => [4] => not successful [5] => ) ) I need it to grab the name of the procedure (CPR-Start Compressions only without Ventilation, Blood Glucose Analysis, etc) then the time if there is one and then the result part at the end (((?:not )?successful)) if there is one. Few notes: The only thing I can count on being there is the name The hyphens in names was screwing me up (ie: Airway-Intubation of Existing Tracheostomy Stoma would end up being: Airway) Thanks for any help - it is greatly appreciated!
-
Perfect! I think you have it all covered it all... +1,000,000
-
You know what, screw the potential hyphens this is pretty damn good enough, if you don't mind accounting for potential hyphens then I would surely use the pattern, but you have already done so much. Seriously, thank you so much, you have have been a massive help. You should have a donate button in your sig, lol.
-
Also names may have hyphens (-) or other symbols, this just keeps getting harder!
-
That shouldn't happen, if it wouldn't be much trouble to incorporate that just to be on the safe side, sure, but I doubt the script would ever see that so it's not a big deal.