jay_waugh
asked on
Identify all characters following the final space in a string
I am trying to gather all of the characters following the final space in a string but am struggling with the syntax. Can anyone help please? The last set of characters will always be alphanumeric but will be of differing characters and amount of charaters.
In the below example I would only want to highlight cat.
dog xxx-klsfkd-sdf-sdf cat
And in the next one aaaaaaaaaaaaaddddddddddddd dd
heht ooijl-nanhjhsh aaaaaaaaaaaaaddddddddddddd dd
Many Thanks
In the below example I would only want to highlight cat.
dog xxx-klsfkd-sdf-sdf cat
And in the next one aaaaaaaaaaaaaddddddddddddd
heht ooijl-nanhjhsh aaaaaaaaaaaaaddddddddddddd
Many Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Shaun
\w includes the underscore character.
\w includes the underscore character.
What underscore do? No underscore in question
https://regex101.com/r/qlAarF/4
https://regex101.com/r/qlAarF/4
Which is why \w is probably not the correct pattern to use for this problem.
Works for all examples give by OP
@Shaun
The question text included this:
In your \w comment, you wrote this:
Since the \w pattern matches the underscore character, it would not be the correct pattern to suggest for this problem/question. I was correcting your suggestion for future readers of this thread and educating the OP. It doesn't matter whether it matches the sample text.
The question text included this:
The last set of characters will always be alphanumeric
In your \w comment, you wrote this:
If you wanted alphanumeric you can use this
Since the \w pattern matches the underscore character, it would not be the correct pattern to suggest for this problem/question. I was correcting your suggestion for future readers of this thread and educating the OP. It doesn't matter whether it matches the sample text.
You're getting closer. Try adding the space character at the start of your pattern.
Are you using Python for this question?