I am trying to modify a bash script. The script current contains
print "<div class=\"title\">" $1 "</div>"
Where $1
may look like:
Apprentice Historian (Level 1)
Historian (Level 4)
Master Historian (Level 7)
What i'd like to do is add an image which is named the "base" value. I had something like this in mind:
print "<div class=\"icon\"><imgsrc=\"icons\" $1 ".png\"></div><div class=\"title\">" $1 "</div>"
However, in this case I'd like $1
to only return Historian
. I was thinking I could use a regex to match and on $1
and keep only the part I need.
(Apprentice|Master)?\s(.*)\s(\(Level \d\))
I know my regex isn't quite there, ideally apprentice/master would be in their own match group and not tied the base. And I don't know how to match on the $1
argument.