Regular expression for the second symbols from the front and the back are equal
You asked two questions.  The usual rule on this site is to ask one question per post.

No, you're not allowed to use variables in regular expressions.  Regular expressions have a formal definition.  To qualify as a regular expression, you need to meet the requirements in the definition.  The definition can be found on Wikipedia or in your favorite textbook, and you'll note that it does not allow "where" or "variables".

For your first question about how to find a regular expression for a language, take a look at How to prove a language is regular?.