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

  • SEARCH
  • Home
  • 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 9156927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:53:18+00:00 2026-06-17T12:53:18+00:00

I want to do replace for the following patterns (the foregoing rule has higher

  • 0

I want to do replace for the following patterns (the foregoing rule has higher priority)

\right)   -> remain unchanged
\right )  -> remain unchanged
\right]   -> remain unchanged
\right ]  -> remain unchanged
\right}   -> remain unchanged
\right }  -> remain unchanged
\ri)      -> \right)
\ri       -> \rightarrow
\right    -> \rightarrow

In other words, if there is any parentheses bracket or brace, I want to have \right, if anything else, it should be replaced by \rightarrow. In short, I was trying transform a lot of shorthanded google doc equations with into proper LaTeX format. What I came up with was the following

sed -i 's/\\ri\([^g]\)/\\right\1/g' $tempfile1  #first step substitution
sed -i 's/\\right\([^])}>|a]\)/\\rightarrow\1/g' $tempfile1 
sed -i 's/\\right \([^])}>|a]\)/\\rightarrow \1/g' $tempfile1 

It works ok except it does not change \right\ into \rightarrow\ as expected. My test input tempfile1 is the following

\ri\right\right \right)\right]\right }\right )\ri \right ]\righta \al \\

It goes into

\rightarrow\right\rightarrow \right)\right]\right }\right )\rightarrow \right ]\rightarrow \alpha \\

Noting that the \right\ part was not done correctly. Then I added the following line, thinking that it will explicit pick up what was left, however, it does not work as expected and now I am really confused…

sed -i 's/\\right\\/\\rightarrow\\/g' $tempfile1 #why this does not work

Thanks a lot in advance!

  • 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-17T12:53:19+00:00Added an answer on June 17, 2026 at 12:53 pm

    The trouble occurs when the expression:

    sed -i 's/\\right\([^])}>|a]\)/\\rightarrow\1/g'
    

    is applied to:

    \right\right\
    

    The first match reads \right\ and replaces it with \rightarrow\; the problem occurs when the scan resumes, it starts at the r of the second right, not with the backslash (that was part of the previous match).

    The simple trick is to repeat the command…

    sed -i -e 's/\\right\([^])}>|a]\)/\\rightarrow\1/g' \
           -e 's/\\right\([^])}>|a]\)/\\rightarrow\1/g'
    

    The rescan deals with the second \right\ sequence by starting ab initio again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to replace part of the following html text (excerpt of a huge
I'm getting used to Haskell's higher-order functions. Usually I can replace explicit patterns of
I want to capture the following pattern using Regex in C# and replace it
Let's suppose I have the following regex: -(\d+)- and I want to replace, using
hello I want replace following phrase: tinymce/jscripts/tiny_mce/plugins/emotions/img/smiley-cool.gif with: http://mysite.com/tinymce/jscripts/tiny_mce/plugins/emotions/img/smiley-cool.gif I have tried : $comments
i have the following code.My table is called 'tableu'.I want replace 'tableu' with a
I want to replace everything except the following: spaces ( ) numbers AND OR
Lets say I want to replace the following string within a textfile: document.write(unescape(%3Cscript src='
I want replace a(or each) element(number) instead another element(number) in a class while running
I want to replace some headers by images, so I would have nice font.For

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.