Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4633

Regular expression to select symbol with only digits in word

$
0
0

Can't create a regular expression that would select the "X" symbol that is between digits and a word does not contain other letters or "X" is on the first or last place of a word. Examples:

  1. test123X123test - should not find X because there are letters in word
  2. test 123X123 test - should find X because there is no letters (except X) in word
  3. 123X123 test - should find X
  4. test 123x123 - should find X
  5. 123X - should not find X because X is on the last place
  6. X123 - should not find X because X is on the first place

I was wondering if anyone could help me. Btw I use ruby, so the regular expression must work with it.


Viewing all articles
Browse latest Browse all 4633

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>