I have a variable like this:
$hint = "Hint: Hello World – kind regards – monday night"
I want just the full content.
$hint = ($hint).Substring(5) and if $hint is longer than 20 charaters, then cut the rest off
example: $hint = "Hello World – kind regards"
I just want the middle of the content -> from charatert 8 to 20
Have anyone an idea for this problem
thanks in advance
I'm not completely sure if I got what you're asking for ...
That would be something like this or not:
What means "too long" ... anyway that would be this:
That would be something like this:
You might explain more detailed what you need.
Like Olaf, I'm not 100% certain what you're after. I have assumed you want up to 20 characters of the hint text, but not the 'Hint: ' text at the start of the string. Using $myString.substring(6,20) will return an error if the string is shorter than 20 characters long so you need to allow for shorter hints.
I would use a regular expression to match 0 – 20 characters after the 'Hint: '
Breaking down the regex:
Edit: posted code on Gist because it contains angled brackets.
Without trying to be a smart ass but to be correct – the expression would return an error when the string is shorter than 26 charachters. 😉 😀
Good catch. I appreciate the correction.
You must be logged in to reply to this topic.