How to get the index of space before specific string?

emilly

I have below string

String = "Test1 Test2 Test3 Test4 Test5 Test6  15min"

I want to get the index of character space before string "min"

There is a method like String.lastIndexOf(" ") but could not find any thing related?

EDIT:-

Basically want to find last space before the first min

ControlAltDel

First get the position of the string that you want to get the space before, then use that position to get the closest previous position of space

int idx1 = str.indexOf("min");
int lastSpace = str.lastIndexOf(" ", idx1);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to Extract the middle characters from a string without an specific index to start and end it before the space character is read?

From Dev

How to get String with specific index - swift

From Dev

How do I get all the rows before a specific index in Pandas?

From Dev

How to get the index of a String after the first space in vbsript

From Dev

Get characters before last space in string

From Dev

Get characters before last space in string

From Dev

How to get characters from a specific index from a string in java

From Dev

How to get index from List<string> of specific item?

From Dev

How to get characters from a specific index from a string in java

From Dev

How to get a specific character from index of a string in swift

From Dev

How to add space before a particular string in python

From Dev

How to get specific index of a Dictionary?

From Dev

How to remove a specific white space in a string python

From Dev

How to remove a specific white space in a string python

From Dev

How to remove space and the specific character in string - awk

From Dev

How to get the string before "_" in PHP

From Dev

How to get string before hyphen

From Dev

How to remove white space after and before specific character?

From Dev

Ruby - How to split a string before specific keywords

From Dev

How to match two strings before a specific string

From Dev

How to print string before specific word in bash?

From Dev

Regex: Get specific string without characters before and after the string

From Dev

how to match everything between a string and before next space

From Dev

Regex: How to leave out string + space before a domain or IP address?

From Dev

how to match everything between a string and before next space

From Dev

How to get the output of `find` as a space separated string?

From Dev

How to get the output of `find` as a space separated string?

From Dev

How to get a specific field of a string

From Dev

How to replace one character at a specific index in a string

Related Related

  1. 1

    How to Extract the middle characters from a string without an specific index to start and end it before the space character is read?

  2. 2

    How to get String with specific index - swift

  3. 3

    How do I get all the rows before a specific index in Pandas?

  4. 4

    How to get the index of a String after the first space in vbsript

  5. 5

    Get characters before last space in string

  6. 6

    Get characters before last space in string

  7. 7

    How to get characters from a specific index from a string in java

  8. 8

    How to get index from List<string> of specific item?

  9. 9

    How to get characters from a specific index from a string in java

  10. 10

    How to get a specific character from index of a string in swift

  11. 11

    How to add space before a particular string in python

  12. 12

    How to get specific index of a Dictionary?

  13. 13

    How to remove a specific white space in a string python

  14. 14

    How to remove a specific white space in a string python

  15. 15

    How to remove space and the specific character in string - awk

  16. 16

    How to get the string before "_" in PHP

  17. 17

    How to get string before hyphen

  18. 18

    How to remove white space after and before specific character?

  19. 19

    Ruby - How to split a string before specific keywords

  20. 20

    How to match two strings before a specific string

  21. 21

    How to print string before specific word in bash?

  22. 22

    Regex: Get specific string without characters before and after the string

  23. 23

    how to match everything between a string and before next space

  24. 24

    Regex: How to leave out string + space before a domain or IP address?

  25. 25

    how to match everything between a string and before next space

  26. 26

    How to get the output of `find` as a space separated string?

  27. 27

    How to get the output of `find` as a space separated string?

  28. 28

    How to get a specific field of a string

  29. 29

    How to replace one character at a specific index in a string

HotTag

Archive