473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to go backward direction in any string

198 100+
Hi
i want to move in a back direction in any string
just like substring function in which we can move from a particular location to another location in forward direction but i want to move backword direction

can you suggest me any way how ican do this

varinder
Jun 5 '08 #1
4 1315
r035198x
13,262 8TB
Hi
i want to move in a back direction in any string
just like substring function in which we can move from a particular location to another location in forward direction but i want to move backword direction

can you suggest me any way how ican do this

varinder
Strings have an index just like an array which you can use to retrieve any character in the string.
Jun 5 '08 #2
jamesd0142
469 256MB
Take a look at the mid() function... I think this might solve your query
Jun 5 '08 #3
If you are trying to capture a part of the string from some position within the string backwards to the beginning, you could use the length property (or length-index), and a for/next loop in VB. This is only a logical solution if you do know the relative position within the string where you want to start but do not know how many characters you want.

VB
Expand|Select|Wrap|Line Numbers
  1.  for n = length-1 to 0 Step -1 
  2. newstring=oldstring[n]+newstring
  3. next n
  4.  
//This captures everything from the end of the string (going backwards) until
// it encounters a space
C#
Expand|Select|Wrap|Line Numbers
  1.  for (int n=length-1;n>=0;n--) 
  2. {
  3. if(oldstring[n]=" ")
  4. {
  5. break;
  6. }
  7. newstring=oldstring[n]+newstring;
  8. }
  9.  
Jun 5 '08 #4
Plater
7,872 Expert 4TB
Hi
i want to move in a back direction in any string
just like substring function in which we can move from a particular location to another location in forward direction but i want to move backword direction

can you suggest me any way how ican do this

varinder
So if a string was
"A man and his dog went walking"

And you wanted to start on the h of "his" and go backwards 5 characters. do you want returned string to be "and h" or "h dna"(reversed).
One can be done easily with substring(), the other would be better with the for loop
Jun 5 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Eric Wichterich | last post by:
Hello, I am converting a perl-script to python and have problems with this simple perl-statement: for ( $i = 100; $i > 2; $i-- ) {do something } Does anyone know how to write this in...
2
by: Robert | last post by:
I need to find the location of a short string in a long string. The problem however is that i need to search backward. Does anybody know how to search in reverse direction? Thanks, Robert
1
by: Vyacheslav Lanovets | last post by:
Hello, All! Installed VS 2005... What is annoying is that project files are not backward compatible. For instance, EVC4 vcp files are backward compatible with EVC3 and can be used...
13
by: SpOiLeR | last post by:
Hi! Let's assume I have this typedef std::list<std::string> string_list; string_list sl; If I want to traverse through this, I usually do this: string_list::iterator i = sl.begin();
2
by: Dominic | last post by:
Hi everybody, I'm planning to use serialization to persist an object (and possibly its child objects) in my application. However, I'm concerned about the backward compatibility issue. I'm...
3
by: Madhu | last post by:
We are having a dll backward compatibility issue since we migrated to .NET 2005. As part of our product, we build a dll which is used by other products. Everything was fine when we were build it...
2
by: samueltilden | last post by:
I started a new job and the version of Visual Studio 2005 that I am now using does not have the Navigate Backward Button nor the Navigate Forward Button in the Standard Toolbar, and they are not...
2
by: gpspocket | last post by:
how to generate date backward from end to start like this begin -- loop to insert date backward while @end_date>=@start_Date begin INSERT INTO @tb_temp
45
by: hank | last post by:
I have this code here, it converts decimal numbers to binary. There is one problem. The output is printed 'in reverse' and I have no clue at all how to solve this problem. Output of program: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.