Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Online Members
naveensanagasetti
baskar
Joe
Arvind kumar
More...
Forums
»
.NET
»
.NET
»
Help need with Regular Expression in C#
Posted Date:
11 Jan 2008
Posted By::
Manoj V
Member Level:
Bronze
Member Rank:
0
Points
: 2
Responses:
2
I have a string s="kYY2034924324YYYYYYYGdsfjldksjdsjfflYYYYYYY1234YY".
I need to replac YY ( NOT YY in YYYYYYY) with 'xx'.
i.e output must be "kxx2034924324YYYYYYYGdsfjldksjdsjfflYYYYYYY1234xx"
Pls help. Urgent.
Tweet
Responses
#178436 Author:
Subhashini Janakiraman
Member Level:
Silver
Member Rank:
1714
Date: 11/Jan/2008 Rating:
Points
: 2
Iam just puzzled by the question.Here is my answer.Here when you execute the procedure you will get the solution in vb.net
In a procedure by name change2,
public sub change2()
dim s as string="kYY2034924324YYYYYYYGdsfjldksjdsjfflYYYYYYY1234YY".
dim arr(s.length-1) as char
dim i as integer
dim str as string=""
for i=0 to s.length-1
arr(i)=s.substring(i,1)
next
Do while(i<=s.length-1)
if arr(i)="Y" then
if arr(i+1)="Y" then
if arr(i+2)<>"Y" then
arr(i)="X"
arr(i+1)="X"
endif
endif
endif
i=i+1
Loop
for i=0 to s.length-1
str=str& arr(i)
Next
textbox1.text=str
end sub
IF you want the solution in C#.net
public static void change2()
{
string s="kYY2034924324YYYYYYYGdsfjldksjdsjfflYYYYYYY1234YY";
int i;
char[] arr=new char[s.length];
while(i<s.length)
{
char a=Convert.toChar(s.substring(i,1));
arr[i]=a;
i=i+1;
}
for(i=0;i<s.length-3;i++)
{
if(arr[i]=='Y')
{
If(arr[i+1]=='Y')
{
if(arr[I+2]!='Y')
{
arr[i]='x';
arr[i+1]='x';
}
}
}
i=i+1;
}
for(i=0;i<s.length;i++)
{
string str=str+arr[i];
}
Console.WriteLine("The new string is "+str);
}
Dear Manoj,
When I tried this program in computer it did not work out.Sorry.Hope you will find suitable solution .
#178451 Author:
Manoj V
Member Level:
Bronze
Member Rank:
0
Date: 11/Jan/2008 Rating:
Points
: 2
Thank you very much for providing the solutin, Subhashini Janakiraman.
Post Reply
This thread is locked for new responses. Please post your comments and questions as a
separate thread
.
If required, refer to the URL of this page in your
new post
.
Tweet
Next :
send query for update and delete
Previous :
GC
Return to Discussion Forum
Post New Message
Category:
Related Messages
Is there any expert to solve this?
what is difference between String and string(data type) in c#?
what is a resource file...
Horizontal Scroll Bar for a listview control
sql querry
Active Members
Today
Prachi Kulkarn...
(37)
baskar
(26)
Hemanth
(25)
Last 7 Days
Naved Hasan ...
(255)
naveensanagase...
(238)
Pawan Awasthi
(176)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds
Talk to Webmaster Tony John