-1

Unfortunately I found that the existing examples are confusing and not similar enough to what I am trying to achieve. I need a regular expression to find occurencies of strings like

=> Test[a]

where between the special character > and Test there is exactly one space. The word Test can be replaced by any alphabetic string (=> Apple[b] is another example). I have worked out a regex for all except the first part with the block =>.

Can anyone help me?

axiac
  • 56,918
  • 8
  • 77
  • 110
Giuseppe
  • 573
  • 1
  • 8
  • 15
  • 1
    How about... `"=> "`? What is exactly the trouble here with the space? – Wiktor Stribiżew Sep 10 '19 at 10:10
  • 1
    *'I have worked out a regex'* Care to show that to us? – CinCout Sep 10 '19 at 10:10
  • Thanks everyone and sorry. I thought I needed to escape special characters and do something about spaces. I am using this expression in notepad++ – Giuseppe Sep 10 '19 at 10:15
  • .(=>) [a-zA-Z]+\[a\]\. – Giuseppe Sep 10 '19 at 10:15
  • it now works :-) – Giuseppe Sep 10 '19 at 10:15
  • You are not clear regarding what you want to capture, and how. `(=>\s[^ ]+)` capture all the string, `(=>\s[^ ]+)\[[a-zA-Z]\]` capture only => Test , `=>\s([^ ]+)\[([a-zA-Z])\]` capture Test and a divided, `(?<==>\s)([^ ]+)\[([a-zA-Z])\]` is like previous one, but match without =>\s, and so on. If you specify better what you have to do it's easier to answer – brazoayeye Sep 10 '19 at 10:23

2 Answers2

-1

I managed to find this expression

.(=>) [a-zA-Z]+\[a\]\.

and it works! Thanks everyone.

axiac
  • 56,918
  • 8
  • 77
  • 110
Giuseppe
  • 573
  • 1
  • 8
  • 15
  • It's not working, according to https://regex101.com/ . Maybe you means `(=>) [a-zA-Z]+\[a\]`, that's not working with => Apple[b]? – brazoayeye Sep 10 '19 at 10:27
-2

Try use this regex:

=> \S+

Here Is Demo

ut or
  • 36
  • 9