Replace StringCKChetan koralli15yAsked Jan 20, 2012, 4:54 AM ESTSolvedShareLinkedInXCopy linkSaveHi,can any one help me,my string is as folllowsstring pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001";i want last "IMAGEPDF" should be Replaced with "PDF".Thanks&Regards,Chetan.k4 AnswersKnow the answer? Post it. Somebody with the same question will find it here.FMFormer member15y agoPosted Jan 20, 2012, 5:01 AM EST✓ Accepted answer0CodeCopyHope this helps you. string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001"; int idx = pdfPath.LastIndexOf("IMAGEPDF"); pdfPath = pdfPath.Remove(idx, 5);0JSjit sun28 points15y agoPosted Jan 20, 2012, 5:33 AM EST0Hi,string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001"; pdfPath = pdfPath.Replace("IMAGEPDF", "PDF");i think it helpsjitendra0RMRashed Mohammad17 points15y agoPosted Jan 20, 2012, 5:40 AM EST0Hi,Here is the full code. This will replace "IMAGEPDF" by "PDF" (or anything instead of "PDF")using System;class StringHandle{ static void Main() { string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001"; string repStr = "IMAGEPDF"; int idx = pdfPath.LastIndexOf(repStr); int length = repStr.Length; pdfPath = pdfPath.Remove(idx, length); pdfPath = pdfPath.Insert(idx, "PDF"); Console.WriteLine(pdfPath); }}First this removes the last "IMAGEPDF" and then it is replaced by "PDF". You can test it by any string to replace "IMAGEPDF".0CKChetan koralli12 points15y agoPosted Jan 22, 2012, 7:09 PM EST0Thanks Murli Your reply helped me0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign in
Replace StringCKChetan koralli15yAsked Jan 20, 2012, 4:54 AM ESTSolvedShareLinkedInXCopy linkSaveHi,can any one help me,my string is as folllowsstring pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001";i want last "IMAGEPDF" should be Replaced with "PDF".Thanks&Regards,Chetan.k
FMFormer member15y agoPosted Jan 20, 2012, 5:01 AM EST✓ Accepted answer0CodeCopyHope this helps you. string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001"; int idx = pdfPath.LastIndexOf("IMAGEPDF"); pdfPath = pdfPath.Remove(idx, 5);0
JSjit sun28 points15y agoPosted Jan 20, 2012, 5:33 AM EST0Hi,string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001"; pdfPath = pdfPath.Replace("IMAGEPDF", "PDF");i think it helpsjitendra0
RMRashed Mohammad17 points15y agoPosted Jan 20, 2012, 5:40 AM EST0Hi,Here is the full code. This will replace "IMAGEPDF" by "PDF" (or anything instead of "PDF")using System;class StringHandle{ static void Main() { string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001"; string repStr = "IMAGEPDF"; int idx = pdfPath.LastIndexOf(repStr); int length = repStr.Length; pdfPath = pdfPath.Remove(idx, length); pdfPath = pdfPath.Insert(idx, "PDF"); Console.WriteLine(pdfPath); }}First this removes the last "IMAGEPDF" and then it is replaced by "PDF". You can test it by any string to replace "IMAGEPDF".0
Former memberPosted Jan 20, 2012, 5:01 AM EST
jit sun28 pointsPosted Jan 20, 2012, 5:33 AM EST
string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001";
pdfPath = pdfPath.Replace("IMAGEPDF", "PDF");
i think it helps
jitendra
Rashed Mohammad17 pointsPosted Jan 20, 2012, 5:40 AM EST
Here is the full code. This will replace "IMAGEPDF" by "PDF" (or anything instead of "PDF")
using System;
class StringHandle
{
static void Main()
{
string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001";
string repStr = "IMAGEPDF";
int idx = pdfPath.LastIndexOf(repStr);
int length = repStr.Length;
pdfPath = pdfPath.Remove(idx, length);
pdfPath = pdfPath.Insert(idx, "PDF");
Console.WriteLine(pdfPath);
}
}
First this removes the last "IMAGEPDF" and then it is replaced by "PDF". You can test it by any string to replace "IMAGEPDF".
Chetan koralli12 pointsPosted Jan 22, 2012, 7:09 PM EST