Hello fellow AppleScripter and RegexPros,
I am just starting to learn more about Regex and I am a little stuck with matching a pattern.
I have more than 5000 lines of a csv. All columns are delimited by tab.
example row
A a year (4 digits long)
B a number or number & characters including whitespace various length
C a number or number & characters including whitespace various length
D a number or number & characters including whitespace various length
How can I just find/match C (basically everything between 2nd tab & 3rd tab)?
I want to get the linenumber of a matching row and the contents of the row itself using grep by matching Column C by a Pattern.
The searchstring will be dynamic and changed. Since the seachstring can also appear in Column D i have to be sure it gets searched only in column C
Here is what I came up with so far:
set searchstring to "Pk 155"
set pattern to "" -here i need the RegEx for matching
set matching_line to do shell script "grep" ___________
--grep -n pattern file.txt | cut -d : -f 1
set linenumber to do shell script "grep -n" & space & pattern & space & quoted form of myFile & space & "| cut -d : -f 1"
I think I have to use parentheses somewhere but wherever I put them I dont get the right stuff(in the examplerow just “Pk 155”)
Hope I explained it so you can follow me.