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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:13:42+00:00 2026-05-11T22:13:42+00:00

I need to perform a find and replace using XSLT 1.0 which is really

  • 0

I need to perform a find and replace using XSLT 1.0 which is really suited to regular expressions. Unfortunately these aren’t available in 1.0 and I’m also unable to use any extension libraries such as EXSLT due to security settings I can’t change.

The string I’m working with looks like:

19;#John Smith;#17;#Ben Reynolds;#1;#Terry Jackson

I need to replace the numbers and ; # characters with a ,. For example the above would change to:

John Smith, Ben Reynolds, Terry Jackson

I know a recursive string function is required, probably using substring and translate, but I’m not sure where to start with it.

Does anyone have some pointers on how to work this out? Here’s what I’ve started with:

<xsl:template name="TrimMulti">
    <xsl:param name="FullString" />
    <xsl:variable name="NormalizedString">
        <xsl:value-of select="normalize-space($FullString)" />
    </xsl:variable>
    <xsl:variable name="Hash">#</xsl:variable>
    <xsl:choose>
        <xsl:when test="contains($NormalizedString, $Hash)">
            <!-- Do something and call TrimMulti -->
        </xsl:when>
    </xsl:choose>
</xsl:template>
  • 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-11T22:13:42+00:00Added an answer on May 11, 2026 at 10:13 pm

    I’m hoping you haven’t simplified the problem too much for asking it on SO, because this shouldn’t be that much of a problem.

    You can define a template and recursively call it as long as you keep the input string’s format consistent.

    For example,

    <xsl:template name="TrimMulti">
      <xsl:param name="InputString"/>
      <xsl:variable name="RemainingString" 
        select="substring-after($InputString,';#')"/>
      <xsl:choose>
        <xsl:when test="contains($RemainingString,';#')">
          <xsl:value-of 
            select="substring-before($RemainingString,';#')"/>
          <xsl:text>, </xsl:text>
          <xsl:call-template name="TrimMulti">
            <xsl:with-param 
              name="InputString"
              select="substring-after($RemainingString,';#')"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$RemainingString"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    

    I tested this template out with the following call:

    <xsl:template match="/">
      <xsl:call-template name="TrimMulti">
        <xsl:with-param name="InputString">19;#John Smith;#17;#Ben Reynolds;#1;#Terry Jackson</xsl:with-param>
      </xsl:call-template>
    </xsl:template>
    

    And got the following output:

    John Smith, Ben Reynolds, Terry Jackson
    

    Which seems to be what you’re after.

    The explanation of what it is doing is easy to explain if you’re familiar with functional programming. The InputString parameter is always in the form [number];#[name];#[rest of string]. Each call of the TrimMulti template chops off the [number];# part and prints off the [name] part, then passes the remaining expression to itself recursively.

    The base case is when InputString is in the form [number];#[name], in which case the RemainingString variable won’t contain ;#. Since we know this is the end of the input, we don’t output a comma this time.

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

Sidebar

Ask A Question

Stats

  • Questions 152k
  • Answers 152k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SUBSTRING(MyValue, CHARINDEX ('/', MyValue) + 1, 8000) May 12, 2026 at 10:03 am
  • Editorial Team
    Editorial Team added an answer On the WindowsMobile.Status class you can check the PhoneSignalStrength property. May 12, 2026 at 10:03 am
  • Editorial Team
    Editorial Team added an answer $("#ibtnArchive").click ( function () { // code for opening your… May 12, 2026 at 10:03 am

Related Questions

Lately, I've come across a lot of Java code that relies on properties files
I have a few things that I cannot find a good way to perform
First post, so here goes. I'm writing a script that does intelligent search and
Currently in my ASP.Net applications web.config I have an application setting that stores a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.