Hi, I am trying to use Regex within a PDF questionnaire and populate the values from that questionnaire to an online form
I want to be able to grab the last word from the sentence, however, the last word can differ depending on the person filling in the questionnaire.
For example, when extracted the pdf file to text file, one of the questions is, ‘21 Name of Institution ABC School’ - I want to get the value ABC School from that sentence. Most questions values are Yes and No so I also want to be able to retrieve that.
I am new to regex so I am trying to get use to it.
I am not the most experienced here and I really haven’t looked at a Regex solution but what if you do the following:
1- Put that sentence in a String variable.
2- Split that string variable using space character. so arr_var = str_var.split(" ")
3- Extract the last 2 elements of the array
This Regex will suite you perfectly:
This will look at 2 sequences of characters separeted by one space at the end of a line
Won’t work if the text is read in paragraph, but if you take the last match you should be still good
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.