I have:
if (temp.Contains( "Account") == true)
{
temp.Replace("A ccount", "Client");
}
The "Account" is not replaced by "Client" after this operation. I used
debugger and see temp remains the same after "Replace".
Any advice? Thanks! 5 1841
Curious,
Replace() returns the modified string so you'll need:
temp = temp.Replace();
Jason Newell
Software Engineer www.jasonnewell.net
Curious wrote:
I have:
if (temp.Contains( "Account") == true)
{
temp.Replace("A ccount", "Client");
}
The "Account" is not replaced by "Client" after this operation. I used
debugger and see temp remains the same after "Replace".
Any advice? Thanks!
Thanks!
I have another question about Regular Expression. If I use:
if (temp.Contains( "Ending") == true)
{
temp =
System.Text.Reg ularExpressions .Regex.Replace( temp, "Ending",
"Beginning" );
}
It seems that while "Ending" is replaced with "Beginning" , it also
deletes the space after "Ending". For instance, "Period Ending July
31, 2007" is now "Period BeginningJuly 31, 2007" (Note: no space
betweem "Beginning" and "July" after Replace).
Any advice?
Curious wrote:
Thanks!
I have another question about Regular Expression. If I use:
if (temp.Contains( "Ending") == true)
{
temp =
System.Text.Reg ularExpressions .Regex.Replace( temp, "Ending",
"Beginning" );
}
It seems that while "Ending" is replaced with "Beginning" , it also
deletes the space after "Ending". For instance, "Period Ending July
31, 2007" is now "Period BeginningJuly 31, 2007" (Note: no space
betweem "Beginning" and "July" after Replace).
Any advice?
Use string.Replace instead. There is no reason to use Regex.Replace when
you don't have a regular expression.
If you _do_ have a regular expression, but have replaced it in the
example, show the actual code that you are using. It's very hard to find
errors in code that you can't see.
--
Göran Andersson
_____ http://www.guffa.com
Thanks - Either string Replace or Regex Replace works. The problem is
that it doesn't show the correct string in the PDF file...
Curious wrote:
Thanks - Either string Replace or Regex Replace works. The problem is
that it doesn't show the correct string in the PDF file...
Then you have to examine what the data looks like really. Either Replace
method doesn't remove spaces by itself, so it's not the replacement
method that is the problem, but the data that you use it on.
Perhaps the phrase is divided into two text areas, so that changing the
text "Period Ending" doesn't move the date as it's in a separate area.
--
Göran Andersson
_____ http://www.guffa.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Barnes |
last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form?
Here is the scenario:
I have a form that cannot accept apostrophes. I want to use the replace() so that the apostrophe is
automatically replace with two '' . Reason being--SQL Server does not like apostrophes being sent to database.
I've tried to do this on the server side in the SQL area of the ASP page by writing a function (with some great...
|
by: Rick Brandt |
last post by:
Here is a simplified example of what I am passing to a Java SAX parser
within a servlet via an HTTPRequest...
<?xml version="1.0"?>
<Record>
<ID>1092853685</ID>
<Notes><!]></Notes>
</Record>
I get the following error in the server's log output...
|
by: Thomas |
last post by:
It looks like the String.replace doesn't work in IE6.1. Anyone else
has the same problem. I am using newest service package of IE and
Win2K.
Thanks
|
by: vigi98 |
last post by:
Hello all,
Can someone confirme that this:
var strURLpiece = "UK & Ireland";
strURLpiece.replace("&", "%26");
replaces all occurrence of the character & by %26 in strURLpiece, ie
that strURLpiece becomes "UK %26 Ireland" ?
Thanks a lot.
|
by: G. |
last post by:
This is an obvious bug in the String.Replace function:
//load a XML string into a document
XmlDocument doc = new XmlDocument();
doc.LoadXml("<test id='' />");
//Obtain the string again...Converts my '' to ""...strange, but ok.
String strXML = doc.OuterXml;
//trying to convert back the single quotes to double quotes
| |
by: Marty |
last post by:
Hi,
I would like to replace "\r\n" by "_" within a specific string.
I tried :
strMyString.Replace('\r', '_');
strMyString.Replace('\n', '_');
or
strMyString.Replace(System.Environment.NewLine, '_');
|
by: Mark Szlazak |
last post by:
I don't think this is "do-able" but thought I'd better check. Say I
want to replace certain names in some source code as long as they are
not properties (dot properties) of objects. I could use a regular
expression like:
rx = /(?:(\.)|\b)(?:name1|name2|name3)\b/g;
map = ;
map = "a";
map = "b";
|
by: Lonifasiko |
last post by:
Hi,
Just want to replace character at index 1 of a string with another
character. Just want to replace character at that position. I thought
Replace method would be overloaded with an index parameter with which
you can write wanted character at that position. But no, Replace
method only allows replacing one known character with another. The
problem is I don't know the character to replace, just must replace
the character at a known...
|
by: Alun |
last post by:
I need to replace all new line characters in a string with a valid
XHTML line break tag <br />.
I'm trying to use the string.Replace method for this. Here's some
example code:
String description = "This is a video description \n Hello World";
description = description.Replace("\n", "<br />");
Literal1.Text = description;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |