

?- open_string("Hello@",Input), read_string(Input, ",@", "\t ", End, String) Input = <stream>(0x1ca11d0), End = 41, String = "Hello".
Reading user input:
?- read_string(user_input, "\n", "\t ", End, String). |: Hello End = 10, String = "Hello".
Did you know ... | Search Documentation: |
![]() | Predicate read_string/5 |
The predicate read_string/5 called repeatedly on an input until Sep is -1 (end of file) is equivalent to reading the entire file into a string and calling split_string/4, provided that SepChars and PadChars are not partially overlapping.156Behaviour that is fully compatible would require unlimited look-ahead. Below are some examples:
Read a line:
read_string(Input, "\n", "\r", Sep, String)
Read a line, stripping leading and trailing white space:
read_string(Input, "\n", "\r\t ", Sep, String)
Read up to‘,
’or‘)
’,
unifying Sep with 0',
i.e. Unicode 44, or 0')
,
i.e. Unicode 41:
read_string(Input, ",)", "\t ", Sep, String)
?- open_string("Hello@",Input), read_string(Input, ",@", "\t ", End, String) Input = <stream>(0x1ca11d0), End = 41, String = "Hello".
Reading user input:
?- read_string(user_input, "\n", "\t ", End, String). |: Hello End = 10, String = "Hello".