Hi all,
I just got a new task. It is to extract a substring within the longer string. Here is the example,
"Schemes are embedded as those scheme packs as <T501-08815-0103> in 'Schemes to Sign_for_829501.doc'"
The task is to get substring T501-08815-0103
the variation is this < > can be two as <T501-08815-0103, T501-08715-0103>
so in this case the task is to get substring T501-08815-0103, T501-08715-0103
we can tailed the format to make easier to extract substring, like this case using < >, it can be any as long as it is helpful to extract the substring...
Thanks
What is the best way to extract a substring within a longer string?
Moderator: DosItHelp
Re: What is the best way to extract a substring within a longer string?
FOR /F command and use the DELIMS option. Use the <> as the delimiters.
You were shown how to use the TOKENS and DELIMS options in this post.
You were shown how to use the TOKENS and DELIMS options in this post.
Re: What is the best way to extract a substring within a longer string?
Thank you and get what wanted:
Code: Select all
FOR /F "tokens=2,3 delims=<>" %%A IN (scheme_source.txt) DO @echo %%A>>scheme_target.txt