E
E
Egor2018-04-06 13:31:31
Regular Expressions
Egor, 2018-04-06 13:31:31

How to write a regular expression with a condition?

The following strings are possible:
#name
#name#
name# You
need to find characters #only if:
- either it comes at the end
- or it goes both at the beginning and at the end at the same time.
In other words: if there is a character #at the end, then you need to select all the characters #in the string.
Tried through a condition, but it doesn't work: if it's at the end #- then select everything for me #
(#)$(?(1)#)
. How can I compose such a regular expression?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2018-04-06
@NeiroNx

Like this https://regex101.com/r/m08j7m/5 ?

E
Egor, 2018-04-06
@egormmm

Alexander needs to highlight only the characters #without what stands between them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question