How do I use regular expressions for title in embedding settings?

I’m trying to get embedding working on my website to use Discourse as a comment system. I’ve mostly got it working except when it imports a page on my site as a post in Discourse it pulls in the whole html title as the post tile e.g. ‘First blog post | Simon Panrucker!’

‘Simon Panrucker!’ is my website title and I don’t want it to be part of the forum post title. So I want the scrub to stop at ‘| Simon Panrucker!’ - or preferably the space before that.

I couldn’t find anything in this forum to help, and I’ve tried to learn a bit about regular expressions but honestly I have no idea if what I’m doing is the right kind of thing. It’s not working, anyway!

In the box that says ‘Regular expression used to scrub the title of posts’ I’ve put the following:

/(?<=<title>).*[^| Simon Panrucker!] /gm

Can anyone help me understand what I’m doing wrong? Thanks!

1 Like

I figured this out, in case anyone else comes across this problem. I had over complicated it!

In the box that says ‘ Regular expression used to scrub the title of posts ’ you can just put the part of the title where you want the scrub to stop, with a $ on the end. So if the html title of the page is ‘My post name - My Website Name’ you can put ‘- My Website Name$’ (without the quotation marks) in the box and the post that is created in discourse will not include that part of the title.

Hope this makes sense and might be helpful for someone else!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.