用于查找和格式化文本部分的 Jquery 正则表达式
我使用 Jquery 有许多动态生成的反馈行来测验来自 xml 的问题。示例:
您的回答
您的回答
您回答(每周剂量。)您的患者处于中等风险。
等等。
我如何查找反馈文本的不同部分并对其进行格式化?我需要将部分文本的格式设置为斜体引号。还要将末尾的部分文本格式化为粗体,从单词“at”开始直到句点标记?
我想用正则表达式是可能的,但我还没有使用它们。 到目前为止,我有以下内容:
var feedbackString = "<p id='feedbackTxt'>" + currentQuizNode.find("Feedback").text() + "</p>";
$("#quizFeedback").append(feedbackString);
预先感谢您, 阿提拉
I used Jquery to have many dynamically generated feedback lines to quiz questions coming from an xml. Sample:
You answered (Yes.) Your patient is at moderate to high risk.
You answered (No.) Your patient is at low to high risk.
You answered (Weekly Dose.) Your patient is at moderate risk.
etc.
How can I find and format different parts of the feedback text? I need to format part of the text with the quotation marks in italic. Also format part of text at the end in bold starting with the word "at" till the period mark?
I guess it would be possible with regular expressions but I haven't used them.
so far I have the following:
var feedbackString = "<p id='feedbackTxt'>" + currentQuizNode.find("Feedback").text() + "</p>";
$("#quizFeedback").append(feedbackString);
Thank you in advance,
Attila
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
非常丑陋,但它有效:P
very ugly but it works :P
如果您想说的是括号而不是引号,则将:更改
为:
If you meant to say parenthesis instead of quotation marks then change:
To: