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 9077669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:25:40+00:00 2026-06-16T19:25:40+00:00

I’m trying to run a regex over an XML file (Jira export file, to

  • 0

I’m trying to run a regex over an XML file (Jira export file, to be precise) to fix an issue with some JQL-queries in it.

I’m looking for an attribute called “request”, it contains a query. In that query, usernames need to be wrapped in HTML-entities for quotes ("quot;).
A username always follows the string “reporter = ‘, “assignee = “, or “watcher = “, except for one special case: the string currentUser() is not a username and does not need to be replaced.

 Original:
 <SearchRequest id="10000" name="Example" author="myusername" user="myusername" request="reporter = anotheruser and status != Closed" favCount="1"/>
 Result:
 <SearchRequest id="10000" name="Example" author="myusername" user="myusername" request="reporter = &quot;anotheruser&quot; and status != Closed" favCount="1"/>

 Search:
 (request=".*?(reporter|assignee|watcher) = )(?!currentUser)([a-z.]+)(.*?")

 Replace:
 $1&amp;$3&amp;$4

This has been tried and tested in SublimeText 2, and Regex Tester 2, and works correctly. As you can see, it uses a lookahead to detect the negative case for currentUser. Now, when I try to use this regex in Sed, it errors out:

$ sed -i '' -E 's/(request=".*?(reporter|assignee|watcher) = )(?!currentUser)([a-z.]+)(.*?")/$1&amp;$3&amp;$4/g' entities.xml
sed: 1: "s/(request=".*?(reporte ...": RE error: repetition-operator operand invalid

I’m not sure how to proceed now, as sed is new territory to me. I’m inclined to think it’s the lookahead that causes this problem. Perhaps there’s a simpler way to fulfil this requirement?

  • 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-16T19:25:42+00:00Added an answer on June 16, 2026 at 7:25 pm

    Unfortunately lookaheads/behinds are not support in sed you should take a lot at ssed (super sed). Here is the FAQ if you want more information.

    Also this could be done in perl if you are familiar, which I am not (I tagged with perl so you should get some help).

    Using the -P option with grep verifies your match:

    $ grep -Po '(request=".*?(reporter|assignee|watcher) = )(?!currentUser)([a-z.]+)(.*?")' <<< '<SearchRequest id="10000" name="Example" author="myusername" user="myusername" request="reporter = anotheruser and status != Closed" favCount="1"/>'
    request="reporter = anotheruser and status != Closed"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an ASP request returning a XML file containing some latin characters. By
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
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.