Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. ([A-Z][a-z0-9]+)+
  2.  
  3. ([A-Z][a-z0-9]+){2,}
  4.  
  5. [A-Z]([A-Z0-9]*[a-z][a-z0-9]*[A-Z]|[a-z0-9]*[A-Z][A-Z0-9]*[a-z])[A-Za-z0-9]*
  6.  
  7. [a-z]+((d)|([A-Z0-9][a-z0-9]+))*([A-Z])?
  8.  
  9. xmlHttpRequest
  10. newCustomerId
  11. innerStopwatch
  12. supportsIpv6OnIos
  13. youTubeImporter
  14. youtubeImporter
  15. affine3D
  16.  
  17. ([A-Z][a-z0-9]+)((d)|([A-Z0-9][a-z0-9]+))*([A-Z])?
  18.  
  19. XmlHttpRequest
  20. NewCustomerId
  21. InnerStopwatch
  22. SupportsIpv6OnIos
  23. YouTubeImporter
  24. YoutubeImporter
  25. Affine3D
  26.  
  27. b[A-Z][a-z]*([A-Z][a-z]*)*b
  28.  
  29. (^[A-Z][a-z0-9]+[A-Z]$)|(^[A-Z][a-z0-9]+([A-Z][a-z0-9]+)+$)|(^[A-Z][a-z0-9]+([A-Z][a-z0-9]+)+[A-Z]$)
  30.  
  31. 1. First character uppercase alpha
  32. 2. Next 1-n characters lowercase alphanumeric
  33. 3. Next character (n+1) uppercase alpha
  34. 4. Next 0 or more characters lowercase alphanumeric
  35. No consecutive uppercase; no special characters.
  36. Pattern may be repeated, e.g. NoChildLeftBehindSuite9102
  37.  
  38. Camel01C is CamelCase syntax
  39. Camel01c01 is not CamelCase syntax
  40. Camel01C01 is CamelCase syntax
  41. Camel01CC01 is not CamelCase syntax
  42. Camel0a1c1 is not CamelCase syntax
  43. Camel0a1C1 is CamelCase syntax
  44. Camel0ac1b1C1 is CamelCase syntax
  45. CamelC is CamelCase syntax
  46. CamelC1 is CamelCase syntax
  47. CamelCA is not CamelCase syntax
  48. CamelCa1 is CamelCase syntax
  49. CamelCa_1 is not CamelCase syntax
  50. IbsReleaseTestVerificationRegressionSuite is CamelCase syntax
  51. IbsReleaseTestVerificationRegressioNSuite is not CamelCase syntax
  52. IbsReleaseTestVerificationRegressioN is CamelCase syntax
  53.  
  54. /^[A-Z][a-z]+([A-Z][a-z]+)+/
  55.  
  56. require 'test/unit'
  57.  
  58. REGEX = /^[A-Z][a-z]+([A-Z][a-z]+)+/
  59.  
  60. class RegExpTest < Test::Unit::TestCase
  61. # more readable helper
  62. def self.test(name, &block)
  63. define_method("test #{name}", &block)
  64. end
  65.  
  66. test "matches camelcased word" do
  67. assert 'FooBar'.match(REGEX)
  68. end
  69.  
  70. test "does not match words starting with lower case" do
  71. assert ! 'fooBar'.match(REGEX)
  72. end
  73.  
  74. test "does not match words without camel hump" do
  75. assert ! 'Foobar'.match(REGEX)
  76. end
  77.  
  78. test "matches multiple humps" do
  79. assert 'FooBarFizzBuzz'.match(REGEX)
  80. end
  81. end
  82.  
  83. ([A-Z][a-zd]+)+
  84.  
  85. ([A-Z]+[a-z0-9]+)+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement