I am going to reverse engineer this to suggest "it's a long shot" intent
For the sake of illustration, I'll use three martial characters (partially optimized) at level 11 who get swallowed in the first round. You offered up level ranges from 9-13, so I took the middle value. When you observe that
it seems very unlikely to me that an unoptimized swallowed character
in the Level 9-13 range would be able to get close to doing enough
damage to cause the behir to maybe regurgitate the character.
you are correct. The analysis below shows that even with some optimization (Fighter and Barbarian cases), it is very difficult, so an unoptimized character will have more trouble.
30 HP makes it "hard to get out" for a "level appropriate encounter"
The behir case confirms your estimate that "it's supposed to be a long shot". The PC needs a little help from the dice to get that 30 HP in one round, and thus have a chance to get puked out of a behir. It is a two step process; the PC needs the benefit of slightly cold dice when the behir rolls that Con save.
Being blinded and being restrained causes attacks to be at disadvantage. This is where getting multiple blows to land can be a problem - it generally takes multiple blows (unless the paladin gets a crit on a smite) to get the 30 HP or more needed to even force the Con save. I think you can see that 30 HP is a good number to pick if the dev requires that there be a little luck involved (or maybe creative application of game features that apply advantage) to cut one's self out of a behir.
Assumptions
Armor Class from within is 17, since that is the only AC value offered in the Behir's stat block.
No magic weapons. The influence of a flat +1 or a flat +2 skews the numbers up a bit, but per some old dev comments along the lines of "the game can be completed (level 1-20) without magic items" we won't assume any.
Three martial characters seeking fulfillment as behir puke
I'll offer up three standard martial characters: A champion Fighter, a Barbarian, and a Paladin to illustrate.
Case 1: Fighter, Champion, 11, critical hit on a 19 or a 20.
Polearm Mastery, Strength: 20; Con 16, prof bonus = 4, HP = 103 (avg HP per PHB)
TN to hit AC 17 = 8 (17-(+5 +4) = 8) A roll of 8-20 hits
- TN to hit, with disadvantage = 13/20 x 13/20 = .4225 chance to hit on a
given attack.
- With four attacks (three attacks and a bonus attack with the polearm mastery feat)
((1d10 +5 x 3) + (1d4 +5)) x .4225 = 16.4775
That's not the 30 HP needed.
If the Fighter took Great Weapon Fighting style (which amounts to roughly a +1 increase in DPR per attack), 19.4775, we are still not at 30 HP.
Fighter stays in the guts without a little luck on the die rolls.
What about Criticals Hits? With disadvantage, we get 4 chances in 400 to score a crit: rolls of 19, 19; 19, 20; 20, 19; and 20, 20. 1.01 times the above doesn't look to improve much, but if a crit comes, great!
And then there's the Con save
Let's say the Fighter rolls high and hits often enough to do 30 damage. With a Con modificer of +4, Behir needs a 10 to pass the Con save and avoid puking. On a given round, that's a 55% chance to keep the fighter in the guts and apply 21 (6d6) acid damage even if the 30 + threshold is reached.
The Fighter took damage to be bitten {22 (3d10 + 6)} and get swallowed. On each turn after the swallow (assuming no previous damage) 21 more HP from a pool of 103. At 60 HP (at end of Behir's second turn) this fighter lasts three more rounds in the guts before the acid drops HP to 0. The total number of attack attempts from within aftger being swallowed is 4. If the Figher's are able to kill the behir before then, the fighter can crawl out.
Case 2: Barbarian, Bear Totem, level 11, Great Axe, Great Weapon Mastery
Strength: 20; Con 16, proficiency bonus = 4, HP = 115 HP. (Average)
- Barbarian is at disadvantage, but is not subject to melee attacks inside the behir, and so Barb will use reckless attack (grants advantage) to counter the disadvantage of being Restrained.
- Two attacks with a TN of 8. (.65 to hit for a given attack)
- DPR is pretty straighforward, but since critical hits are speicial with GWM, we'll break this down. (Great axe is d12, average damage = 6.5).
- 0.65 x ((6.5 +5 +3 (rage) x 2)) = 18.85.
- Not 30 HP, unless two hits happen (37.7). Barb needs help from the dice.
- But, with a crit, we add another 6.5 (average Great Axe damage), and another 6.5 (Brutal Critical) and another attack from GWM!
- (.65 x 14.5) = 9.425 + 13 + 18.85 = 41.275" - well over 30 HP.
- The chance for a crit with two attacks is a bit over 1/10. It may happen, but don't count on it.
- Should the Barb try for a -5 hit +10 Damage GWM feature?
- TN is now 13 so to hit is .40.
- .4 x ((6.5 +5 +3 (rage) +10 x 2)) = 19.6. Sure, why not, it takes two hits or a crit to exceed 30 HP.
- A single successful hit will do: 6.5(weapon) + 8(rage + Str bonus) + 10 = 24.5, better than a single successful hit doing 18.85. (Still not 30). It takes rolling a 12 on the d12 for a mighty blow to start the puking process (30 damage)
- Two hits with the -5 / +10 will get the barfing started.
- Barb has 8 or 9 rounds to score that kind of damage, so why not try - there is still a 55% chance to stay in the guts due to Behir's Con save.
- The Barbarian will live longer inside the guts. Why? Rage.
- Barb keeps taking damage, Barb keeps raging. Damage is halved.
- Barb took damage to be bitten and get swallowed, 11 (half of 22 (3d10 + 6) piercing) damage, after the swallow and round 1 of being digested, (21 damage, reduced to 10) and has taken 21 HP from a pool of 115 ijn two rounds. At 94 HP, the Barb can last another 8 or 9 rounds while trying to cut themselves out of the Behir before the acid drops HP to 0. If the allies of the Barb are able to kill the behir before then (likely) Barb can crawl out.
Case 3: Paladin, level 11.
Str 20, Con 16, no feats, Sword and Board.
Two attacks, TN = 8, with disadvantage, to hit as Fighter: .4225.
Acid duration as with Fighter. Damage taken / HP as with fighter.
- With one successful hit, Paladin can do, with a Long Sword + Divine Smite
- 4.5 + 5 + 4d8 (3d level spell, smite) = 9.5 + 18 = 27.5. Almost 30 HP.
- With two hits in one round, + smite, the Paladin is looking for puke ejection to commence.
- With one hit, and slightly favorable damage rolls with the sword and the smite, 30 HP, start the puking.
- With a crit, and the additional 4d8 + 1d8, 30 HP easily exceeded.
- But, if the Behir's Con save is made some of the subsequent smite attempt roll 3d8s, 2d level spells, or 2d8's, 1st level spells, so the damage average drops a bit.
It's the Con Save that will frustrates puke ejection efforts
In any case of internal damage, there is a 55% chance that the puking won't start and the Paladin (or other swallowed character) needs help from their allies.
Your instincts are good: the numbers show that 30 HP makes it "a long shot"
It is most likely that only with the assistance of allies will the PC get out of the Behir's guts: 168 HP is what's needed to kill one with average HP.
However, a few nice rolls gives the swallowed character a chance to be puked out.
If a spell caster has Blink prepared ...
The reason why I didn't use casters in my examples are many, but spells like this is one such reason since using damage to get out is bypassed by this spell. (This spell does not require concentration).
Casting Time: 1 action Range: Self Components: V, S Duration: 1 minute
Roll a d20 at the end of each of your turns for the duration of the
spell. On a roll of 11 or higher, you vanish from your current plane
of existence and appear in the Ethereal Plane (the spell fails and the
casting is wasted if you were already on that plane). At the start of
your next turn, and when the spell ends if you are on the Ethereal
Plane, you return to an unoccupied space of your choice that you can
see within 10 feet of the space you vanished from. If no unoccupied
space is available within that range, you appear in the nearest
unoccupied space (chosen at random if more than one space is equally
near). {snip} While on the Ethereal Plane, you can see and hear the
plane you originated from, which is cast in shades of gray, and you
can’t see anything there more than 60 feet away
Out as soon as an 11 is rolled: it's not an I-win button, but it's a decent way out if the d20 isn't horribly cold. The problem a caster may have is not enough acid resistance to stay alive for more than a few rounds once that initial 22 and 21 damage (average) is taken.
In game experience with CR 1 Giant Toads and being swallowed.
Our level 11 ranger was scouting a side passage and got jumped by giant toads. CR 1. They nearly did for him when one swallowed him during round 1 of combat. He had the darnedest time getting out. Part of the problem was that he'd exit prone, and another toad would attack with advantage ...