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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:06:51+00:00 2026-05-15T18:06:51+00:00

The following code outputs: http://www.google.com http://www.google.com&lang What is the simplest way to change the

  • 0

The following code outputs:

http://www.google.com 
http://www.google.com&lang

What is the simplest way to change the code so it outputs:

http://www.google.com 
http://www.google.com&lang=en¶m2=this¶m3=that

CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestRegex9928228
{
    class Program
    {
        static void Main(string[] args)
        {
            string text1 = "try out [url=http://www.google.com]this site (http://www.google.com)[/url]";
            Console.WriteLine(text1.ExtractParameterFromBbcodeUrlElement());

            string text2 = "try out [url=http://www.google.com&lang=en&param1=this&param2=that]this site (http://www.google.com)[/url]";
            Console.WriteLine(text2.ExtractParameterFromBbcodeUrlElement());

            Console.ReadLine();
        }
    }

    public static class StringHelpers
    {
        public static string ExtractParameterFromBbcodeUrlElement(this string line)
        {
            if (line == null)
                return "";
            else
            {
                if (line.Contains("]"))
                {
                    List<string> parts = line.BreakIntoParts(']');
                    if (parts[0].Contains("="))
                    {
                        List<string> sides = parts[0].BreakIntoParts('=');
                        if (sides.Count > 1)
                            return sides[1];
                        else
                            return "";
                    }
                    else
                        return "";
                }
                else
                    return "";
            }
        }

        public static List<string> BreakIntoParts(this string line, char separator)
        {
            if (String.IsNullOrEmpty(line))
                return new List<string>();
            else
                return line.Split(separator).Select(p => p.Trim()).ToList();
        }
    }
}
  • 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-05-15T18:06:51+00:00Added an answer on May 15, 2026 at 6:06 pm

    Simplest or most efficient? You’re asking two different questions it seems. Simplest would be something like this:

    Change:

    List<string> sides = parts[0].BreakIntoParts('=');
    if (sides.Count > 1)
       return sides[1];
    

    To:

    List<string> sides = parts[0].BreakIntoParts('=');
    if (sides.Count > 1)
       return parts[0].Replace(sides[0], "");
    

    Edit: Looks like you changed title to remove “most efficient”. Here’s the simplest change (fewest lines of code changed) that I see.

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

Sidebar

Related Questions

Using the following string: http://www.google.com.ar/setprefs?prev=http://www.google.com.ar/&sig=0_Kxz_cp1G52p8pcrDBlMIQhwJAL0%3D&suggon=2 https://plus.google.com/?gpsrc=ogpy0&tab=wX http://www.google.com.ar/webhp?hl=es&tab=ww http://www.google.com.ar/imghp?hl=es&tab=wi http://video.google.com.ar/?hl=es&tab=wv http://news.google.com.ar/nwshp?hl=es&tab=wn http://translate.google.com.ar/?hl=es&tab=wT https://mail.google.com/mail/?tab=wm http://www.google.com.ar/intl/es/options/ http://books.google.com.ar/bkshp?hl=es&tab=wp
I'm following two tutorials from Google: http://code.google.com/apis/maps/articles/phpsqlgeocode.html http://code.google.com/apis/maps/articles/phpsqlajax_v3.html#createmap I have the first tutorial working
I have the following code: $.get('http://www.example.org', {a:1,b:2,c:3}, function(xml) {}, 'xml'); Is there a way
I'm using the following code to create an xls file from php. http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8 However,
I have the following code: http = Net::HTTP.new(www.something.com, 80) http.set_debug_output($stdout) http.post(/blah, something, {'random-parameter' =>
Please consider the following URLs: http://www.mydomain.com/a/test.php https://www.mydomain.org/a/b/test.php http://www.mydomain.co.nr/a/b/c/test.php https://www.mydomain.com/a/b/c/d/test.php http://www.mydomain.co.uk/a/b/c/d/e/test.php https://www.mydomain.co.au.nm/a/b/c/d/e/f/test.php?var1=test1&var2=test2 Now I want
I have the following code: page = Net::HTTP.get_response(URI.parse('http://www.enhancetv.com.au/tvguide/rss/melbournerss.php')).body rescue nil show_info = Hash.from_xml(page).to_json puts
Sigh, regex trouble again. I have following in $text : [img]http://www.site.com/logo.jpg[/img] and [url]http://www.site.com[/url] I
I am using the Following code <?php $url = 'http://www.ewwsdf.org/012Q/rhod-05.php?arg=value#anchor'; $parse = parse_url($url); $lnk=
I have the following code: <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output method=html /> <xsl:key name=categories match=Category

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.