I collect data from a pdf file, so I convert pdf to txt and get data from it. I get the master entry in a line like this.
CARDS 1 GA350C 3 2 0 . 0 450.0 DIGCL R 90 . 0 55.0 2Y 4 4 #
when there is only one record, and someday I get several records in one line, like this, I understood with the “#” symbol, which exists more than one record in a line.
Invite 1 MA300C 3 2 0 . 0 450.0 DIGCL R 9 9 . 0 210.0 6 Y 4 4 #RSVP 1 OFF-90 A 1 3 2 0 . 0 450.0 DIGBH S 9 9 . 0 210.0 6 N 1 0 #Letter1 1 MA130C 3 2 0 . 0 450.0 DIGC L R 29 7 . 0 210.0 2 N 4 0 #Letter1 1 OFF-90 A 1 3 2 0 . 0 450.0 DIGBH S 29 7 . 0 210.0 2 N 1 0 #Envelopes 1 ENVDL E P F S 3 2 0 . 0 450.0 DIGBH S 13 0 . 0 225.0 1 N 1 0 #
In the first line, the actual line should like
CARDS 1 GA350C 320.0 450.0 DIGCLR 90.0 55.0 2 Y 4 4
It’s worth Y Yes, so this the symbol used to be N stands No ::
How can I combine numbers and letters in the way I showed? It should work regardless of the length of the string . I used
$string = "CARDS 1 GA350C 3 2 0 . 0 450.0 DIGCL R 90 . 0 55.0 2Y 4 4 #";
$newstring = preg_replace("/(\d+)\s+(?=\d+)/", "$1", $string);
But no luck, does anyone have a solution please? Thanks for watching this question.