We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 334888b commit 8a9fd5bCopy full SHA for 8a9fd5b
1 file changed
src/openmc_mcnp_adapter/parse.py
@@ -46,6 +46,8 @@
46
_COMPLEMENT_RE = re.compile(r'(#)[ ]*(\d+)')
47
_NUM_RE = re.compile(r'(\d)([+-])(\d)')
48
49
+_HAS_REPEAT_RE = re.compile(r'\b\d+[rR]\b')
50
+
51
_REPEAT_RE = re.compile(r"""
52
(?P<value> # The numeric value to be repeated
53
[+-]? # Optional sign
@@ -364,10 +366,11 @@ def sanitize(section: str) -> str:
364
366
section = re.sub('\n {5}', ' ', section)
365
367
368
# Expand repeated numbers
- section = _REPEAT_RE.sub(
- lambda m: ' '.join([m.group('value')] * (int(m.group('count')) + 1)),
369
- section,
370
- )
+ if _HAS_REPEAT_RE.search(section):
+ section = _REPEAT_RE.sub(
371
+ lambda m: ' '.join([m.group('value')] * (int(m.group('count')) + 1)),
372
+ section,
373
+ )
374
375
return section
376
0 commit comments