How to get string before hyphen

Aquarius24

I have below filename:

pagecounts-20150802-000000

I want to extract the date out of above 20150802 I am using the below code but its not working:

print os.path.splitext("pagecounts-20150802-000000")[0]
Alex

The methods in os.path are mainly used for path string manipulation. You want to use string splitting:

print 'pagecounts-20150802-000000'.split('-')[1]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP Regex to get value after and before hyphen ( - )

From Dev

Regex get text before and after a hyphen

From Dev

Regex get text before and after a hyphen

From Dev

How to explode a string on a hyphen in Java?

From Dev

How to get the string before "_" in PHP

From Dev

Get last part of string after hyphen

From Dev

Get string from URL containing hyphen/dash (-)

From Dev

Get all possible combinations for a hyphen separated string

From Dev

remove the word in a string before first occurrence of hyphen or underscore in R

From Dev

regex to get the text before email id and hyphen with space

From Dev

How to split a string based on either a colon or a hyphen?

From Dev

How to convert arrayList to string separated by hyphen

From Dev

how to remove hyphen from string +xslt

From Dev

How to convert arrayList to string separated by hyphen

From Dev

How to get the index of space before specific string?

From Dev

Swift : How to get the string before a certain character?

From Dev

How to replace all the digits before hyphen with a new digit using MySQL?

From Dev

Break a subtitle before hyphen

From Dev

How to match single digits and digits separated by a hyphen with string.match?

From Dev

how to split a string to 4 characters sub strings then concat them by hyphen?

From Dev

how to split a string to 4 characters sub strings then concat them by hyphen?

From Dev

How to keep hyphen in output string with preg_replace

From Java

How would I get everything before a : in a string Python

From Dev

how to get value before and behind decimal point in string

From Dev

django app how to get a string from a function before

From Dev

How can I get a after and before match in a string?

From Dev

How to get the characters before the last “-” only if the string after the last "-" is numeric?

From Dev

REGEXP to NOT match if there is a hyphen before a variable

From Dev

Isolate leading portion of string before first hyphen and omit any trailing spaces from match

Related Related

  1. 1

    PHP Regex to get value after and before hyphen ( - )

  2. 2

    Regex get text before and after a hyphen

  3. 3

    Regex get text before and after a hyphen

  4. 4

    How to explode a string on a hyphen in Java?

  5. 5

    How to get the string before "_" in PHP

  6. 6

    Get last part of string after hyphen

  7. 7

    Get string from URL containing hyphen/dash (-)

  8. 8

    Get all possible combinations for a hyphen separated string

  9. 9

    remove the word in a string before first occurrence of hyphen or underscore in R

  10. 10

    regex to get the text before email id and hyphen with space

  11. 11

    How to split a string based on either a colon or a hyphen?

  12. 12

    How to convert arrayList to string separated by hyphen

  13. 13

    how to remove hyphen from string +xslt

  14. 14

    How to convert arrayList to string separated by hyphen

  15. 15

    How to get the index of space before specific string?

  16. 16

    Swift : How to get the string before a certain character?

  17. 17

    How to replace all the digits before hyphen with a new digit using MySQL?

  18. 18

    Break a subtitle before hyphen

  19. 19

    How to match single digits and digits separated by a hyphen with string.match?

  20. 20

    how to split a string to 4 characters sub strings then concat them by hyphen?

  21. 21

    how to split a string to 4 characters sub strings then concat them by hyphen?

  22. 22

    How to keep hyphen in output string with preg_replace

  23. 23

    How would I get everything before a : in a string Python

  24. 24

    how to get value before and behind decimal point in string

  25. 25

    django app how to get a string from a function before

  26. 26

    How can I get a after and before match in a string?

  27. 27

    How to get the characters before the last “-” only if the string after the last "-" is numeric?

  28. 28

    REGEXP to NOT match if there is a hyphen before a variable

  29. 29

    Isolate leading portion of string before first hyphen and omit any trailing spaces from match

HotTag

Archive