I need to convert an input-string with multipe words into a string-array via Powershell. Words can be separated by multiple spaces and/or linebreaks. Each word can be escaped by a single quote or a double quote. Some words may start with a hashtag - in that case any quoting appears after that hashtag.
Here a code sample of a possible input and the expected result:
$inputString = @"
test1
#custom1
#"custom2" #'custom3'
#"custom ""four""" #'custom ''five'''
test2 "test3" 'test4'
"@
$result = @(
'test1'
'#custom1'
'"#custom2"'
"#'custom3'"
'#"custom ""four"""'
"#'custom ''five'''"
'test2'
'"test3"'
"'test4'"
)
Is there any solution to do this via a clever RegEx-expression? Or does someone have a parser-snippet/function to start with?