05-13-2014
To find nth position of character in string
Hi guyz i want to know nth position of character in string. For ex.
var="UK,TK,HK,IND,AUS"
now if we see 1st occurance of , is at 3 position, 2nd at 6,..4th at 13 position.
1st position we can find through INDEX, but what about 2nd,3rd and 4th or may be upto nth position. ?
In oracle we had instr there we could provide the nth number occurance also. Here how we can achieve it ?
FYI i am beginner in unix and i m using KSH
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How to I get the nth character from a string in shell script. For instance, I have a string London. I want to get, say the first character (L) from the string. How do I do this in unix shell?
Thankx (4 Replies)
Discussion started by: toughman
4 Replies
2. Shell Programming and Scripting
I need a script for...
how to find a position of column data and print some string in the next line and same position
position should find based on *HEADER8* in text
for ex: ord123 abs 123 987HEADER89 test234
ord124 abc 124 987HEADER88 test235
... (1 Reply)
Discussion started by: naveenkcl
1 Replies
3. Shell Programming and Scripting
I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (2 Replies)
Discussion started by: manaswinig
2 Replies
4. Shell Programming and Scripting
I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (1 Reply)
Discussion started by: manaswinig
1 Replies
5. Shell Programming and Scripting
Hello everyone this is my first post of many to come :)
I am writing a script and in this script at one point i need to replace a character in a particular position in a string for example:
in the string "mystery" i would need to replace the 3rd position to an "r" so the string becomes... (3 Replies)
Discussion started by: snipaa
3 Replies
6. Shell Programming and Scripting
how to find character positionin file?
i.e
string = "123X568"
i want to find the position of character "X".
Thanks (6 Replies)
Discussion started by: LiorAmitai
6 Replies
7. Shell Programming and Scripting
Suppose there are two files:
A, format is like:
line1 12
line2 33
line3 6
...
B, format is like:
>header
taaccctaaccctaaccctaacccaaccccaccccaaccccaaccccaac
ccaaccctaaccctaaccctaacccaaccctaaccctaaccctaacccaa
ccctcaccctcaccctcaccctcaccctcaccctcaccctcaccctaacc... (1 Reply)
Discussion started by: bioinflix
1 Replies
8. Emergency UNIX and Linux Support
I want to replace 150th character of all the lines in a file using sed or awk...
searched the forums but didn't find exact answer (9 Replies)
Discussion started by: greenworld123
9 Replies
9. Shell Programming and Scripting
Hi,
i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command.
thanks in advance,
Sara (9 Replies)
Discussion started by: Sara183
9 Replies
10. Shell Programming and Scripting
I see a millioin ways to do this with echo, but what I wan to do is assign a variable the "nth" character of an incoming parameter to a ksh script.
$1 will be "pia"
I need to assign the first character to stmttype. (10 Replies)
Discussion started by: klarue
10 Replies
LEARN ABOUT CENTOS
xmtextfindstringwcs
XmTextFindStringWcs(library call) XmTextFindStringWcs(library call)
NAME
XmTextFindStringWcs -- A Text function that finds the beginning position of a wide character text string
SYNOPSIS
#include <Xm/Text.h>
Boolean XmTextFindStringWcs(
Widget widget,
XmTextPosition start,
wchar_t *wcstring,
XmTextDirection direction,
XmTextPosition *position);
DESCRIPTION
XmTextFindStringWcs locates the beginning position of a specified wide character text string. This routine searches forward or backward for
the first occurrence of the string, starting from the given start position. If a match is found, the function returns the position of the
first character of the string in position. If the match string begins at the current position, this routine returns the current position.
widget Specifies the Text widget ID.
start Specifies the character position from which the search proceeds. This is an integer number of characters from the beginning of
the text buffer. The first character position is 0 (zero).
wcstring Specifies the wide character search string.
direction Indicates the search direction. It is relative to the primary direction of the text. The possible values are
XmTEXT_FORWARD
The search proceeds toward the end of the buffer.
XmTEXT_BACKWARD
The search proceeds toward the beginning of the buffer.
position Specifies the pointer in which the first character position of the string match is returned. This is an integer number of char-
acters from the beginning of the buffer. The first character position is 0 (zero). If the function returns False, this value is
undefined.
For a complete definition of Text and its associated resources, see XmText(3).
RETURN
Returns True if a string match is found; otherwise, returns False.
RELATED
XmText(3) and XmTextFindString(3).
XmTextFindStringWcs(library call)