0

How can I find the first character in a string that is the space character and return its index, with a single expression that can be used as part of Contract_Cases?

For example, if the string is:

Input : constant String := "abc def";

then the expression should return 4.

rid
  • 61,078
  • 31
  • 152
  • 193

1 Answers1

4

The question originally asked for the first non-blank character in the string, for which you need Ada.Strings.Fixed.Index_Non_Blank (ARM A.4.3(12) and (61)).

As amended (the first blank character in the string), use Ada.Strings.Fixed.Index - see the OP’s comment below.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • 1
    Thanks, this works! My question was wrong though (I'm looking for the first space, not non-space), so in this case it looks like I can use `Ada.Strings.Fixed.Index` ([ARM A.4.3(8.1/2)](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-A-4-3.html#I5809) and [(56.1)](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-A-4-3.html#p56.1)). – rid Nov 10 '17 at 08:13