Django 管理员:让人们测试正则表达式?
我正在构建一个 Django 应用程序,它可以让研究人员向研究参与者发送短信并解析响应。虽然解析“Y/N”和数字将非常容易,但我们需要发送需要更复杂响应的消息。我认为这意味着正则表达式。
这一切都很容易;然而,我想做的事情是让研究人员测试他们的正则表达式,看看它对各种响应有何作用。因此,我有一个包含正则表达式的文本框、一个包含测试响应的文本框以及一个用于查看发生情况的按钮。
如果我只是构建一个应用程序,这又会很容易——有没有办法在 Django 管理应用程序的范围内做到这一点?
I'm building a Django app that will let researchers send text messages to study participants and parse the responses. While parsing, say, 'Y/N' and numbers is going to be pretty easy, we'll need to send messages that need more complex responses. Which, I think, means regular expressions.
All this is easy enough; the thing I want to do, however, is let researchers test their regex to see what it does to various responses. So, I'd have a text box with a regex, a text box with a test response, and a button to see what happens.
If I were just building an app, this would again be easy -- is there a way to do this within the confines of the Django admin app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,将其作为 JavaScript 小部件来实现是最简单的——它会更容易融入到管理中,并且有大量的示例可供使用。
不过,如果敢于稍微偏离这个问题,我会说,尝试编写正则表达式来解析任何复杂的人类生成的响应时,我会非常紧张,特别是如果提交模式是短信或其他智能手机文本。我的猜测是,拼写错误会毁了你的一天(尽管显然我不知道你正在收集什么样的数据)。
My guess is that it would be easiest to do this as a javascript widget--it'll be easier to wedge into the admin and there's tons of examples to work off of.
Daring to venture slightly off of the question though, I'll say I'd be pretty nervous trying to write regexes to parse human-generated responses of any complexity, particularly if the mode of submission will be text messages or other smartphone text. My guess is that typos will ruin your day (though obviously I don't know what kind of data you are collecting).