问题
This question was probably asked before but there are no proper solutions, at least I am unable to find one.
I have a CMS in C#, the article is saved in the database and what I need it while loading the article it should parse available shortcodes like Wordpress.
string str = "Hello there, show my name as [shortcodeX val="Garth"]";
What I need is some help to parse it based on the shortcode called.
public string shortcodeX(string val)
{
return "hi" + val;
}
string str = ParseStringForShortCode(str);
I hope I am able to explain the requirement here and looking for some help
P.S.: I found something in PHP at Shortcode plugins for own custom cms like wordpress shortcode plugins but since I dont know PHP, its hard for me to understand.
回答1:
This seems what you need: https://github.com/aolde/shortcoder.
You can also install it via NuGet.
来源:https://stackoverflow.com/questions/44815192/shortcode-parser-in-c-sharp