Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Example:

# Objects:
math =
  root: Math.sqrt
  square: square
  cube: (x) -> x * square x

# Splats:
race = (winner, runnners...) ->
  print winner, runners

I want to match cube and race (variables/objects that store functions).

I realized I can't use ^w because it won't match the words with a space behind, like cube.

What regex should I use in this case?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
268 views
Welcome To Ask or Share your Answers For Others

1 Answer

with your current example, this pattern would find those text:

/zsS+zes*[:=]s*(

it matches text, which followed by any number of spaces and a : or = then any number of spaces, then a (. I hope this is what you are looking for.

I used S+ instead of w because I don't kown if char like -, # etc. also could be used as variable name.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...