Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Problem in string.Replace()Problem in string.Replace()
Previous
 
Next
New Post
6/20/2008 12:33 AM
 

halo guys,

i have a code like this,

String s="Deepak is working in ACSL";

s.Replace("acsl","Prodigy");

when i execute the above code the "ACSL" in String "s" is not getting replaced with Prodigy.Only when i do like below it gets replaced.

s.Replace("ACSL","Prodigy");

Also

s.Contains("AcSl")

returns false

But how to achieve the previous one.

Kindlly help me in achieving this.

All replies are appreciated

 
New Post
6/20/2008 1:44 AM
 

That because the .Replace is case sensitive. That's why the second .Replace works. Are you going to be trying to take a user's input and compare it against a string that's already there and you want to be able to search no matter what the case is?

 
New Post
6/20/2008 9:11 AM
 

deepak

Please use RegularExpressions instead String. RegEx allows to replace without case sensitive. For example:

Public Dim regex As Regex = New Regex( _
      "acsi", _
    RegexOptions.IgnoreCase _
    Or RegexOptions.Multiline _
    Or RegexOptions.CultureInvariant _
    Or RegexOptions.IgnorePatternWhitespace _
    Or RegexOptions.Compiled _
    )


' This is the replacement string
Public Dim regexReplace As String = _
      "_"


'' Replace the matched text in the InputText using the replacement pattern
' Dim result As String = regex.Replace(InputText,regexReplace)

Hope it will help.

Sergey

 
New Post
6/20/2008 12:18 PM
 

The replace method is case sensitive but the replace function will work fine:

s = Replace(s, "ascl", "Prodigy" , 1, -1, CompareMethod.Text)

I hope this is of some help to you.


Dwayne J. Baldwin
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Problem in string.Replace()Problem in string.Replace()


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out