It is currently May 15th, 2024, 12:10 am



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Auto get the topic title from the nth line of the post.
PostPosted: March 18th, 2015, 12:09 pm 

Joined: August 1st, 2014, 5:15 pm
Posts: 7
I find myself always forget to change the topic title each time I post, The topic title mostly the 1st line of my post or in the format 1st line / 2nd line. I think it's good to have the feature that auto get the nth line (1st line or 1st/2nd line in my case) of the post to make it topic title


Top
 Profile  
Reply with quote  
 Post subject: Re: Auto get the topic title from the nth line of the post
PostPosted: March 18th, 2015, 12:40 pm 
Site Admin
User avatar

Joined: March 10th, 2011, 11:14 pm
Posts: 12660
Location: Earth
It already exists.

Under message menu (at the top) "Use first line as subject".

_________________
themaPoster | themaCreator | themaManager | themaLeecher | themaRegister


Top
 Profile  
Reply with quote  
 Post subject: Re: Auto get the topic title from the nth line of the post.
PostPosted: March 27th, 2015, 9:45 pm 

Joined: August 1st, 2014, 5:15 pm
Posts: 7
Hi, I just try it but there's problem. I normally use [center] to my post, and that make [center] my topic title not the first line after it.


Top
 Profile  
Reply with quote  
 Post subject: Re: Auto get the topic title from the nth line of the post.
PostPosted: March 29th, 2015, 12:08 pm 
Site Admin
User avatar

Joined: March 10th, 2011, 11:14 pm
Posts: 12660
Location: Earth
There are two ways:

1. Don't use [center] tag in first line at all (remove the closing at the end as well).

Add in "CONFIG" -> "Replacements" -> "Message" replacement:

Search for:
Code:
(?s)^.+$


Replace with:
Code:
[center]$0[/center]


Enable regex search.

This will automatically insert the [center] tag around whole post.

2. Don't enter new line after [center] tag. Have it like this:
Code:
[center]Your subject here
Everything else...


Then add in "CONFIG" -> "Replacements" -> "Subject" replacement to just replace that [center] with nothing. Do NOT enable regex. That's not a regex search.

_________________
themaPoster | themaCreator | themaManager | themaLeecher | themaRegister


Top
 Profile  
Reply with quote  
 Post subject: Re: Auto get the topic title from the nth line of the post.
PostPosted: May 17th, 2015, 12:48 pm 

Joined: May 17th, 2015, 10:35 am
Posts: 216
Freddy wrote:
(?s)^.+$

Hello Freddy,

can you please explain if the (?s)-part of the regex is some kind of hard-coded variable for the whole post text? I dealt quite some time with regex but I never have seen such a construction. And a $0 is also uncommon for a capture group, is it something unique to THP?

Thanks in advance for taking the time to answer.

Wurstmu


Top
 Profile  
Reply with quote  
 Post subject: Re: Auto get the topic title from the nth line of the post.
PostPosted: May 17th, 2015, 1:08 pm 
Site Admin
User avatar

Joined: March 10th, 2011, 11:14 pm
Posts: 12660
Location: Earth
Wurstmu wrote:
Freddy wrote:
(?s)^.+$

Hello Freddy,

can you please explain if the (?s)-part of the regex is some kind of hard-coded variable for the whole post text? I dealt quite some time with regex but I never have seen such a construction. And a $0 is also uncommon for a capture group, is it something unique to THP?

Thanks in advance for taking the time to answer.

Wurstmu


Hi,

themaPoster uses Java based regex, but they are almost the same in all languages.

http://docs.oracle.com/javase/7/docs/ap ... ttern.html

(?s) - enables dotall mode. In dotall mode, the expression . (dot) matches any character, including a line terminator.

One more common flag which I use a lot is (?i) - enables case-insensitive matching.

They can be combined if needed like this: (?si) . These flags must be at the start of expression (before regular expression) if needed.

$0 is default capturing group for whole match.

_________________
themaPoster | themaCreator | themaManager | themaLeecher | themaRegister


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Theme designed by stylerbb.net © 2008
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All times are UTC