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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:06:41+00:00 2026-06-16T00:06:41+00:00

I want to replace some substrings in a string with wiki markup. E.g. I

  • 0

I want to replace some substrings in a string with wiki markup. E.g. I have a string

some other string before
; Methods
{{columns-list|3|
* [[Anomaly detection|Anomaly/outlier/change detection]]
* [[Association rule learning]]
* [[Statistical classification|Classification]]
* [[Cluster analysis]]
* [[Decision trees]]
* [[Factor analysis]]
* [[Neural Networks]]
* [[Regression analysis]]
* [[Structured data analysis (statistics)|Structured data analysis]]
* [[Sequence mining]]
* [[Text mining]]
}}

; Application domains
{{columns-list|3|
* [[Analytics]]
* [[Bioinformatics]]
* [[Business intelligence]]
* [[Data analysis]]
* [[Data warehouse]]
* [[Decision support system]]
* [[Drug Discovery]]
* [[Exploratory data analysis]]
* [[Predictive analytics]]
* [[Web mining]]
}}
some other string after

I want to replace the original substring by

[[Anomaly detection|Anomaly/outlier/change detection]]
[[Association rule learning]]
[[Statistical classification|Classification]]
[[Cluster analysis]]
[[Decision trees]]
[[Factor analysis]]
[[Neural Networks]]
[[Regression analysis]]
[[Structured data analysis (statistics)|Structured data analysis]]
[[Sequence mining]]
[[Text mining]]
[[Analytics]]
[[Bioinformatics]]
[[Business intelligence]]
[[Data analysis]]
[[Data warehouse]]
[[Decision support system]]
[[Drug Discovery]]
[[Exploratory data analysis]]
[[Predictive analytics]]
[[Web mining]]

I’ve tried some regex expressions to extract stuff in {{ }} first. But I always got None.

ADD: The problem is that I’m only interested in the contents in [[]] which itself is in {{}}. I have some other occurrences of [[]] in other part of the string.

So, how could I do this by using re.sub? Thanks

ADD: current solution (ugly)

def regt(matchobj):
  #store matchobj.group(0) somewhere else, later on add them to the string
  #Next, another function will remove all {{}} alway
  return ''

matches = re.sub(r'\[\[.*?\]\](?=[^{]*\}\})', regt,wiki_string2)
  • 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-16T00:06:42+00:00Added an answer on June 16, 2026 at 12:06 am

    Match it instead of replacing it

    \[\[.*?\]\](?=[^{]*\}\})
    

    .*? matches lazily.so it would stop at the first time ]] occurs

    .* matches greedily.so it would stop at the last time ]] occurs


    (?=[^{]*}}) is a lookahead which means match content within [[ ]] only if it is followed by 0 to many characters except { till }}..

    This is done because you want to match [[``]] if it is within {{ }}..

    So characters after ]] would be any character except { till }}..

    So this would avoid cases like this

    [[xyz]]<-this would not match since { after it
    {{
    [[xyz]]<-this would match since it is not followed by { and it reaches }}
    [[xyz]]<-this would match since it is not followed by { and it reaches }}
    }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I have some string from XML file, and I I want to replace
I have a long string of some characters. I want to replace some chars
Hi all I have list of type string with some items. i want to
I want to replace some headers by images, so I would have nice font.For
I want to replace some text to other text which contains elements of basic
I have a paragraph of text and i want to replace some words using
When I export to Excel in C#, I want to replace some string like
i want to replace some string(s) from a source string. so that shouldn't be
I want to replace some strings by other one. I use below codes: $mc
When I want to replace some parts of a string, should I call replace

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.