"Moving hashtags from the end of lines to the beginning."

A swapping-ground for Regular Expression syntax

"Moving hashtags from the end of lines to the beginning."

Postby Guy » Sat Mar 29, 2025 8:19 pm

Hi,

I need to move many hashtag symbols across 340 HTML pages using Notepad++, which supports RegEx functionality. While there are numerous hashtag symbols in these files when viewed in Notepad++, I only need to move specific ones from the end of certain lines to the beginning of those same lines.

Fortunately, the hashtags I need to move are preceded by a space and are not directly connected to their related text. These hashtags must not affect other instances, such as in cases like: "background-color: #0056b3", where no space appears after the hashtag. This pattern makes it easier to target only the hashtags that are followed by spaces.

In Notepad++, the hashtags currently appear at the beginning of the lines. However, in the browser, they should display at the end of the lines. The following illustrates how they should be adjusted:

Example:

(Wrong) Before:
# Accessing items with negative indexing.

(Correct) After:
Accessing items with negative indexing #
Guy
 
Posts: 19
Joined: Wed Jan 19, 2022 8:27 am

Moving hashtags

Postby Luuk » Sun Mar 30, 2025 5:38 am

Moving a hashtag to EOL inside of the html, cannot guarantee that a browser displays it that way.
That depends more on moving your hashtags to the right locations inside of your .html files.
And without sample html code, its really just a guessing game for how to move them.
Luuk
 
Posts: 809
Joined: Fri Feb 21, 2020 10:58 pm

Moving hashtags

Postby Luuk » Sun Mar 30, 2025 6:50 am

As an example, if Notepad++ used something like...
(^|>)(#) ([^<>\r\n]+?)\.?($|<)
\1\3 \2\4

It would edit the .html lines like...
# This is text ----------------------------> This is text #
# This is text. ---------------------------> This is text #
color: #0056b3># This is text ----------> color: #0056b3>This is text #
color: #0056b3># This is text. ---------> color: #0056b3>This is text #
<p># Some Text</p>MoreHTMLCode --> <p>Some Text #</p>MoreHTMLCode
aaaaa#bbbbbb#cccccc#ddddd -----------> (not edited)
Luuk
 
Posts: 809
Joined: Fri Feb 21, 2020 10:58 pm


Return to Regular Expressions