Question: I wonder how Fortran's I/O is expected to behave in case of a NULL character `ACHAR(0)`. 

The actual task is to fill an ASCII file by blocks of precisely eight characters. The strings are read from a binary and may contain non-printing characters. 

I tried with `gfortran` 4.8, 8.1 and `f2c`. If there is a NULL character in the string the format specifier `FORMAT(A8)` does **not** write eight characters. 

Give the following F77 code a try: 

```
c Print a string of eight character surrounded by dashes
100   FORMAT('-',A8,'-')
c Works fine if empty or any other combination of printing chars
      write(*,100) ''
c In case of a short sting blanks are padded
      write(*,100) '345678'
c A NULL character does something I did not expect
      write(*,100) '123'//ACHAR(0)//'4567'
c Not even position editing helps
101   FORMAT('-',A8,T10,'x')
      write(*,101) '123'//ACHAR(0)//'4567'
      end

```

My output is:

```
-        -
-  345678-
-1234567-
-1234567x

```

Is this expected behavior? Any idea how to get the output eight characters wide in any case?

Answer: 
This could be a way to get what you need:

```
select regexp_substr(narration, 'chgRs[^\/]+') as derived_narration,
       regexp_substr(narration, '(chgRs)(.+)(GSTR)', 1, 1, '', 2) as charges,
       regexp_substr(narration, '(GSTRs)(\d+\.\d+)', 1, 1, '', 2) as GST
from yourTable

```

With your sample data:

```
SQL> with yourTable(NARRATION) as (
  2      select 'MMT/PS/12345/Family/RAM/chgRs5.00GSTRs0.90' from dual union all
  3      select 'MMT/43425/chgRs5.00GSTRs0.90/1257874554' from dual union all
  4      select 'MMT/XX/12345/Family/RAM/chgRs25.00GSTRs20.90' from dual union all
  5      select 'ITI/4425/chgRs15.00GSTRs10.70/1257874554' from dual
  6  )
  7  select regexp_substr(narration, 'chgRs[^\/]+') as derived_narration,
  8         regexp_substr(narration, '(chgRs)(.+)(GSTR)', 1, 1, '', 2) as charges,
  9         regexp_substr(narration, '(GSTRs)(\d+\.\d+)', 1, 1, '', 2) as GST
 10  from yourTable;

DERIVED_NARRATION         CHARGES    GST
------------------------- ---------- ----------
chgRs5.00GSTRs0.90        5.00       0.90
chgRs5.00GSTRs0.90        5.00       0.90
chgRs25.00GSTRs20.90      25.00      20.90
chgRs15.00GSTRs10.70      15.00      10.70

```
```
with data as (
    select 'MMT/PS/12345/Family/RAM/chgRs5.00GSTRs0.90' as narration from dual union
    select 'MMT/43425/chgRs5.00GSTRs0.90/1257874554' from dual union
    select 'MMT/XX/12345/Family/RAM/chgRs25.00GSTRs20.90' from dual union
    select 'ITI/4425/chgRs15.00GSTRs10.70/1257874554' from dual
)
select regexp_substr(narration, 'chgRs\d+(\.\d{1,2})?'),
       regexp_substr(narration, 'GSTRs\d+(\.\d{1,2})?')
from data

```