Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:04:50+00:00 2026-06-18T03:04:50+00:00

I’m trying another find/replace with regex, and I’ve got some oddball characters that I’m

  • 0

I’m trying another find/replace with regex, and I’ve got some oddball characters that I’m tripping over.

Summary:
Some lines (in this carat separated file) have a specific tag or two in peren’s (either “(S)” or “(N)”) following the part number, and I need to move it to before the PN.
Note: For the lines with both the (S) and the (N), it will always be in that order: (S)(N)

Subject:

^901A-123^DESC,OF,PROD,AND,STUFF^$28.87^$23.10^–^–^–^–^^
^123B-C45(N)^DESC,OF,PROD,AND,STUFF^$1,224.87^$1,041.10^–^–^–^–^^
^333-11(S)(N)^DESC,OF,PROD,AND,STUFF^$510.67^$459.50^$382.90^2^$357.40^4^^
^333-987M-88(S)^DESC,OF,PROD,AND,STUFF^$608.77^$547.90^$456.50^2^$426.10^4^^

What I’ve Tried:
I started out trying stuff like ^(.+)\(N\)^ and ^([A-Za-z0-9]+)\(N\)^, but soon started to wonder whether the ^(carat) was complicating things so I tried escaping it.
That didn’t seem to make a difference 🙂
So next I tried changing all the carats to pipes:

|901A-123|DESC,OF,PROD,AND,STUFF|$28.87|$23.10|–|–|–|–||
|123B-C45(N)|DESC,OF,PROD,AND,STUFF|$1,224.87|$1,041.10|–|–|–|–||
|333-11(S)(N)|DESC,OF,PROD,AND,STUFF|$510.67|$459.50|$382.90|2|$357.40|4||
|333-987M-88(S)|DESC,OF,PROD,AND,STUFF|$608.77|$547.90|$456.50|2|$426.10|4||

… and searching with |([A-Za-z0-9]+)\(N\)|, and now I’m getting … wait for it …..
nothing 🙂

Goal:
While right now I’d be happy with the small victory of figuring out the Find, the ultimate goal is a Replace with a backreference (of the PN).
The goal is to make the subject look like this:

^901A-123^DESC,OF,PROD,AND,STUFF^$28.87^$23.10^–^–^–^–^^
(N)^123B-C45^DESC,OF,PROD,AND,STUFF^$1,224.87^$1,041.10^–^–^–^–^^
(S)(N)^333-11^DESC,OF,PROD,AND,STUFF^$510.67^$459.50^$382.90^2^$357.40^4^^
(S)^333-987M-88^DESC,OF,PROD,AND,STUFF^$608.77^$547.90^$456.50^2^$426.10^4^^

Any and all pointers/suggestions are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:04:51+00:00Added an answer on June 18, 2026 at 3:04 am

    Unfortunately you are fighting with special characters: ^, (), |.
    You need to escape all of them. So you can use this regex (see it in action):

    \^([^\^]+?)(\(S\))?(\(N\))?(\^.*)
    

    and replace with this:

    $2$3^$1$4
    

    I assumed that you have (S) and (N) only after first tag. Output looks like this:

    ^901A-123^DESC,OF,PROD,AND,STUFF^$28.87^$23.10^--^--^--^--^^
    (N)^123B-C45^DESC,OF,PROD,AND,STUFF^$1,224.87^$1,041.10^--^--^--^--^^
    (S)(N)^333-11^DESC,OF,PROD,AND,STUFF^$510.67^$459.50^$382.90^2^$357.40^4^^
    (S)^333-987M-88^DESC,OF,PROD,AND,STUFF^$608.77^$547.90^$456.50^2^$426.10^4^^
    

    Explanation

    Regex:

    \^               #            match '^' character
    ([^\^]+?)        # group 1  : match any char other than '^' one or more times, non-greedy
    (\(S\))?(\(N\))? # group 2-3: match "(S)" and/or "(N)" or none of them
    (\^.*)           # group 4  : match '^' and then everything
    

    Replacement:

    $2$3^$1$4        # concatenate group 2, then 3 and 1 and 4 after a '^' character
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.